js判斷變量類型

 

isNull: function(a){
02     return a === null;
03},
04 isUndefined: function(a){
05     return a === undefined;
06},
07 isNumber: function(a){
08     return typeof a === 'number';
09},
10 isString: function(a){
11     return typeof a === 'string';
12},
13 isBoolean: function(a){
14     return typeof a === 'boolean';
15},
16 isPrimitive: function(b){
17     var a = typeof b;
18     return !!(b === undefined || b === null || a == 'boolean' || a =='number' || a == 'string');      
19},
20 isArray: function(a){
21     return proto_obj.toString.call(a) === '[object Array]';
22},
23 isFunction: function(a){
24     return proto_obj.toString.call(a) === '[object Function]';
25},
26 isPlainObject: function(o){
27     if (!o || o === win || o === doc || o === doc.body) {
28         return false;
29     }
30     return 'isPrototypeOf' in o && proto_obj.toString.call(o) === '[object Object]';       
31},
32 isWindow: function(o){
33     return o && typeof o === 'object' && 'setInterval' in o;
34},
35 isEmptyObject: function(o){
36     for(var in o) {
37     return false;
38     }
39     return true;
40}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值