
NewExpression mostly piggybacks on the existing CallExpression. The big difference is that "new" creates a new Object and passes it as |this| to the callee.
7 lines
103 B
JavaScript
7 lines
103 B
JavaScript
function Foo() {
|
|
this.x = 123;
|
|
}
|
|
|
|
var foo = new Foo();
|
|
if (foo.x === 123)
|
|
console.log("PASS");
|