1. typeof
- typeof 返回类型有7种:string number boolean undefined Function Object Symbol(es6)
- typeof 不能判断数组类型,只能判断数据类型
- typeof 返回的值为字符串,
alert(typeof a == "string") --> true
alert(typeof a == String) --> false
function test(){}
console.log(typeof 1); // number
console.log(typeof test); // function
console.log(typeof "yunxi"); // string
console.log(typeof undefined); // undefined
2.instanceof
返回boolean类型值console.log([] instanceof Array); // true
console.log(/\d+/g instanceof Array); // false
3.constructor
返回boolean类型值console.log(arr.constructor == Array); // true
4.Array.isArray(数组)
返回boolean类型值Array.isArray(state.car) //true