I was told all objects need to have a prototype, however it seems like one can be created with null
var obj= Object.create(null);
so is the above object prototype-less or does it have some unaccessible native object as its prototype, does null not mean it doesn't have a prototype but simply that it doesn't have an author created prototype?
It doesn't have a prototype (or alternatively, the prototype is null
). There are no properties whatsoever accessible from an object created with Object.prototype(null)
.
Observe that the result of Object.getPrototypeOf(Object.create(null))
is null
.