new JavaScript in the constructors have done what

  1. Create a new object
  2. The new object is set as a function of this, in this constructor may be used to refer to the new object (the scope constructor assigns a new object)
  3. Progressive execution of the function code (the code for the constructor is executed, the new object is added to property)
  4. The new object is returned as the return value
			var arr = new Array;
			console.log(arr);
			console.log(Array.prototype);

The following figure on the left is console.log(arr);right is console.log(Array.prototype);
Here Insert Picture Description
seen in this process is equivalent to:

var arr  = {};
arr.__proto__ = Array.prototype;
Array.call(arr);
Published 131 original articles · won praise 451 · views 540 000 +

Guess you like

Origin blog.csdn.net/qq_36667170/article/details/105059385
Recommended