标准对象

    在JavaScript的世界里,一切都是对象。

    但是某些对象还是和其他对象不太一样。为了区分对象的类型,我们用 typeof 操作符获取对象的类型,它总是返回一个字符串:

    typeof 123; // 'number'

    typeof NaN; // 'number'

    typeof 'str'; // 'string'

    typeof true; // 'boolean'

    typeof undefined; // 'undefined'

    typeof Math.abs; // 'function'

    typeof null; // 'object'

    typeof []; // 'object'

    typeof {}; // 'object'

    可见, number string boolean function undefined 有别于其他类型。特别注意 null 的类型是 object Array 的类型也是 object ,如果我们用 typeof 将无法区分出 null Array 和通常意义上的object—— {}