typeof [] 返回值为 object
typeof只能检测数据类型,而不能检测从数据类型中派生的其他类型,数组为object派生对象,所以依然返回object
typeof 判断 引用类型数据,除了function 以外都会判断成为object
function fn(){
console.log(1);
}
console.log(typeof []);//object
console.log(typeof '[]');//string
console.log(typeof 1);//number
console.log(typeof true);//boolean
console.log(typeof null);//object
console.log(typeof undefined);//undefined
console.log(typeof {id:2});//object
console.log(typeof fn);//function
标签:console,log,派生,object,数据类型,typeof
From: https://www.cnblogs.com/longmo666/p/17824779.html