I tested this in Node shell:
var a = {}
a.__proto__ === Object.prototype // true
global.__proto__ === Object.prototype // false
global.__proto__.__proto__ === Object.prototype // true
global.constructor.name // 'Object'
global.__proto__.constructor.name // 'Object'
My question:
why global object (global scope) 's prototype is NOT Object.prototype?
why global's constructor name displayed as 'Object' but it's prototype is not Object.prototype?
every object has an Object at the head of their prototype-chain right before null. The chain is as follows:
null->Object->A->B->C->D
The reason
global.__proto__.__proto__ === Object.prototype // true
works is because it follows null and then Object's prototype, which is the constructor for the new object. Global is the environment.Hope this helps!