js常用类型判断

function isNumber(obj) {  
    return obj === +obj  
}  

function isString(obj) {  
    return obj === obj+''  
}  

function isBoolean(obj) {  
    return obj === !!obj  
}  

function isObject(value) {
    return (typeof value == 'object' || typeof value == 'function') && value != null
}

function isPlainObject(obj) {  
    return typeof obj == 'object' && !Array.isArray(obj) && obj != null && Object.keys(obj).length == 0
} 

 

posted @ 2021-07-16 14:43  全玉  阅读(32)  评论(0编辑  收藏  举报