Object.create(null)

Use Object.create (null) is generated by an object without a prototype object, {} with respect to the direct use of the object generator, which generates a link to the prototype Object.prototype, the former corresponds to a map will not have pure Object .prototype property or method of pollution, natural traversed when the former does not require the use of hasOwnProperty to determine whether the current property owned.

Object.create function of the role is to create an object and let the object parameter as a function of the prototype provided. null as an object, which is Object.prototype prototype, the following code can be verified. Many of the existing methods such as toString, valueOf are all derived from Object.prototype, if so when the prototype of a null object, then the object will not contain any Object.prototype of functions and variables.

Object.prototype.__proto__ === null

Guess you like

Origin www.cnblogs.com/lee88688/p/11225048.html