JavaScript中的isXX系列

isNull: function(a){
    return a === null;
},
isUndefined: function(a){
    return a === undefined;
},
isNumber: function(a){
    return typeof a === 'number';
},
isString: function(a){
    return typeof a === 'string';
},
isBoolean: function(a){
    return typeof a === 'boolean';
},
isPrimitive: function(b){
    var a = typeof b;
    return !!(b === undefined || b === null || a == 'boolean' || a == 'number' || a == 'string');       
},
isArray: function(a){
    return proto_obj.toString.call(a) === '[object Array]';
},
isFunction: function(a){
    return proto_obj.toString.call(a) === '[object Function]';
},
isPlainObject: function(o){
    if (!o || o === win || o === doc || o === doc.body) {
        return false;
    }
    return 'isPrototypeOf' in o && proto_obj.toString.call(o) === '[object Object]';        
},
isWindow: function(o){
    return o && typeof o === 'object' && 'setInterval' in o;
},
isEmptyObject: function(o){
    for(var a in o) {
    return false;
    }
    return true;
}

  

posted @ 2013-12-21 14:59  Childhood Memory  阅读(380)  评论(0编辑  收藏  举报