I ran the following in node.js v0.10.22. I understand this initial object creation snippet:
> var o1 = {};
> var o2 = Object.create(null)
> var o3 = Object.create(Object.prototype);
> var o4 = Object.create({})
> o1
{}
> o2
{}
> o3
{}
> o4
{}
> o1.prototype === void 0
true
> o2.prototype === void 0
true
> o3.prototype === void 0
true
> o4.prototype === void 0
true
However the following confuses me:
> o1 instanceof Object
true
> o2 instanceof Object
false
> o3 instanceof Object
true
> o4 instanceof Object
true
What is the explanation behind this behaviour ?
prototypeto access their prototype - only their constructor function would have such a property. In Chrome, for example, you can access the prototype of an object instance viao1.__proto__trueforo4 instanceof Objectwhen I run your code (node v0.10.13 as well as in Chrome browser console).