JS判断数据类型
1、typeof 返回基本类型(返回的是字符串) number string undefined object(null、array都返回object) function boolean
typeof 100 //number
typeof true //boolean
typeof function //function
typeof undefined //undefined
typeof new Object() //object
typeof [1,2,3] //object
typeof NaN //number
typeof null //object(历史原因返回object)
typeof(typeof true)//string(括号里面的typeof返回的是一个字符串"boolean",再进行类型判断当然是string了)
2、obj instanceof Object 常用于判断某个构造函数的prototype属性是否存在另外一个要检测对象的原型链上,在不同的window或者iframe之间不能使用instanceof进行检测
[1,2,3] instanceof Array ===true;