首页 > 编程语言 > 详细

javascript判断数据类型

时间:2016-02-14 16:47:21      阅读:136      评论:0      收藏:0      [点我收藏+]

整理一下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 }

 

javascript判断数据类型

原文:http://www.cnblogs.com/mitch/p/5189090.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!