JavaScript判断类型
1.typeof操作符,返回值为字符串,用来判断一个值是哪种基本类型
“undefined”-Undefined
"boolean"-Boolean
"string"-String
"number"-Number
"object"-Object或Null
"function:-Function
2.instanceof操作符,返回true/false,确定一个值是哪种引用类型.
console.log(Object instanceof Object);//true
console.log(Function instanceof Function);//true
console.log(Number instanceof Number);//false
console.log(String instanceof String);//false
console.log(Array instanceof Array);//false
console.log(Function instanceof Object);//true
3. 检测数组
(1)value instanceof Array
局限性:对于一个网页或一个全局作用域而言
(2)Array.isArray(vaule)