首页 > Web开发 > 详细

js判断数据类型

时间:2015-12-02 22:25:43      阅读:525      评论:0      收藏:0      [点我收藏+]
 1 //是否是json类型
 2 function isJson(data){
 3     return (typeof data === ‘object‘ && data+‘‘ === ‘[object Object]‘);
 4 }
 5 //是否是数组
 6 function isArray(data){
 7     return data instanceof Array;
 8 }
 9 //是否是简单类型
10 function isSimple(data){
11     if(typeof data === ‘number‘ || typeof data === ‘string‘ || typeof data === ‘boolean‘){
12         return true;
13     }else{
14         return false;
15     }
16 }
17 //是否是引用类型
18 function isRef(data){
19     return !isSimple(data)
20 }

技术分享

js判断数据类型

原文:http://www.cnblogs.com/liuwt365/p/5014168.html

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