js中一切(引用类型)都是对象,值类型不是对象。
引用类型:函数、数组、对象、null、new Number(5)
值类型:undefined, number, string, boolean
typeof属性
function showType() { console.log(typeof x); // undefined console.log(typeof 'abc'); // string console.log(typeof true); // boolean console.log(typeof 10); // number console.log(typeof function () {}); //function console.log(typeof [1, 'a', true]); //object console.log(typeof { a: 10, b: 20 }); //object console.log(typeof null); //object console.log(typeof new Number(10)); //object } showType();