Object.create() // TypeError: Object prototype may only be an Object or null
Object.create(null) //[Object: null prototype] {}
Object.create({}) // {}
The second one is a data dictionary, because it is an object without a parent.
It creates an object that has an empty [[Prototype]] binding (also known as null), and therefore this object cannot delegate anywhere.
As an object of this type does not have a prototype chain, the instanceof operator has nothing to check, so it will always return false.
These special empty [[Prototype]] objects are often called "dictionaries" as they are typically only used to store data in properties, most of the time because they have no surprise effect coming from any delegated property/function in the chain [[Prototype]], and therefore are only used for data storage.
Constructors, in javaScript, it is more appropriate to say that, a "constructor" is any function called with a "new" keyword before it. Functions are not constructors, but function calls are "constructor calls" if and only if "new" is used.
Top comments (0)