The New keyword in JavaScript is completely different from the concept in C#,java.
Example: Var a=new a ();
Let's see what happens with new in JavaScript.
var a={};//set up a new object;
A.__proto__=a.prototype; Point A's prototype to A; Then a inherits the method and properties of a!
A.call (a);//Call the constructor in A;
document.write (A.__proto__===a.prototype);//True
(IE does not support!) Because __proto__ is a private attribute in IE, it cannot be accessed)
So the role of new is actually to build an empty object, and to record the original object's methods and properties through the prototype chain.
So the Var a=new a () is not much different from Var a=new A, they all explain the instructions needed to build the object, such as who the a.__proto__ points to? The name of an empty object? Wait a minute. But one small difference is that if the structure of A is the following:
function A (name,addr) {
This.name=name;
THIS.ADDR=ADDR;
}
Then Var a=new A is not a good object to build.
var a = new A in
JS and the difference from var a = new A ()