判断string,object,array,number的JS函数

    /**
* Check for string
* @param {Object} s
*/
    function isString(s) {
        return typeof s === 'string';
    }
 
    /**
* Check for object
* @param {Object} obj
*/
    function isObject(obj) {
        return typeof obj === 'object';
    }
 
    /**
* Check for array
* @param {Object} obj
*/
    function isArray(obj) {
        return Object.prototype.toString.call(obj) === '[object Array]';
    }
 
    /**
* Check for number
* @param {Object} n
*/
    function isNumber(n) {
        return typeof n === 'number';
    }
原文地址:https://www.cnblogs.com/lfire/p/2701871.html