2.[typeof null, null instanceof Object]的结果
(1)typeof A 返回结果是A的类型。
主要是由6种(number、string、undefined、boolean、function、object)
typeof undefined;//undefined
typeof 'abc';//string
typeof 123;//number
typeof true;//boolean
typeof {};//object
typeof [];//object
typeof null;//object
Object.prototype.__proto__ === null //true
//原型链的源头为null,所有对象都是通过null派生出来的,null本身也被定义为对象(object),
//但是null不具有任何对象的特性,不能执行null.toString()、null.constructor等对象实例的默认调用,
//把null可以理解为尚未存在的对象的占位符,所以'typeof null'返回object字符串。
typeof console.log//function
//特别地
null == undefined; //true
null === undefined; //false
(2)instanceof 用于判断构造函数的prototype属性是否在对象的原型链上
[] instanceof Array //true
{} instanceof Object //true
new Date() instanceof Date //true
//因为null为原型链顶端,而"Object.prototype"有值(表示Object的原型对象),null值并不是以Object为原型创建出来的,显然"null instanceof Object"返回false。
Object.prototype == null //false
null instanceof Object //false
(3)[typeof null, null instanceof Object]的结果
综上(1)(2)所述
[typeof null, null instanceof Object] //["object", false]