zoukankan      html  css  js  c++  java
  • 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;
    }
    

      

  • 相关阅读:
    python类组合
    python 反射 (自省)
    继承 继承 多态
    与属性的深入交流
    与对象的第一次相遇
    MySQL 主从复制
    Redis 配置项
    Redis Cluster 部署
    网络协议和管理
    字符串
  • 原文地址:https://www.cnblogs.com/hcpzhe/p/3485148.html
Copyright © 2011-2022 走看看