---
title: "常用js判断方法[收藏]"
author: "solon.jar"
date: "2011-04-18T09:39:47Z"
tags: []
categories: ["Web前端"]
slug: "js"
draft: false
lastmod: "2011-04-18T09:39:47Z"
id: 1006005
url: "https://solon-jar.iteye.com/blog/1006005"
---

```
转贴
```

```
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;  
}  
```