1.判断是否是数值
function isNumber(obj){ return (typeof obj=='number')&&obj.constructor==Number; }
2.判断是否是字符串
function isString(str){ return (typeof str=='string')&&str.constructor==String; }
3.判断是否是日期
function isDate(obj){ return (typeof obj=='object')&&obj.constructor==Date; }
4.判断是否是数组
function isArray(obj){ return (typeof obj=='object')&&obj.constructor==Array; }
5.判断是否是对象
function isObject(obj){ return (typeof obj=='object')&&obj.constructor==Object; }
6.判断是否是函数
function isFunction(obj){ return (typeof obj=='function')&&obj.constructor==Function; }
微信扫码查看本文
发表评论