标签:
整理一下javascript判断数据类型的函数
1 function isNumber(obj) { 2 return Object.prototype.toString.call(obj) === "[object Number]"; 3 } 4 function isString(obj) { 5 return Object.prototype.toString.call(obj) === "[object String]"; 6 } 7 function isBoolen(obj) { 8 return Object.prototype.toString.call(obj) === "[object Boolen]"; 9 } 10 function isFunction(obj) { 11 return Object.prototype.toString.call(obj) === "[object Function]"; 12 } 13 function isArray(obj) { 14 try { 15 Array.prototype.toString.call(obj); 16 return true; 17 } catch(e) {} 18 return false; 19 } 20 function isNaN(obj) { 21 return obj !== obj; 22 } 23 function isNull(obj) { 24 return obj === obj; 25 } 26 function isUndefined(obj) { 27 return obj === void 0; 28 }
标签:
原文地址:http://www.cnblogs.com/mitch/p/5189090.html