我想实例,是由一个函数返回一个构造函数,但是注意的是new
是一个有点古怪一下:JavaScript:为什么我的`new`需要parens?
// This function returns a constructor function
function getConstructor(){ return function X(){this.x=true} }
getConstructor(); //=> function X(){this.x=true}
new getConstructor(); //=> function X(){this.x=true}
new (getConstructor()); //=> X {x: true}
为什么在括号需要的?
'新新新功能(){返回功能(){返回函数I(){this.cannot = '偶数'}}}'谢谢:d – ChaseMoskal