NewExpression : new NewExpression
function evaluate(new NewExpression) {
var ref = evaluate(NewExpression);
var constructor = GetValue(ref);
if (Type(constructor) != 'object') throw TypeError;
if (!([[Construc]] in constructor)) throw TypeError;
return constructor.[[Construct]]();
}
Note that this production explicitly allows the new operator to be used without parenthesis. So "new Object;" and "new Object();" are the same because a new Object is created for both and no parameters are supplied for both. There is no noticable difference. Note that syntactically, you could even do "new new Object".
NewExpression : new MemberExpression Arguments
function evaluate(new MemberExpression Arguments) {
var ref = evaluate(MemberExpression);
var constructor = GetValue(ref);
var argList = evaluate(Arguments); // returns a List
if (Type(constructor) != 'object') throw TypeError;
if (!([[Construc]] in constructor)) throw TypeError;
return constructor.[[Construct]](argList);
}