码迷,mamicode.com
首页 > Web开发 > 详细

js判断数据类型

时间:2015-12-02 22:27:58      阅读:215      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!