在‘new’操作符中使用.application()。这个是可能的吗?
new
function Something(){ // init stuff}function createSomething(){ return new Something.apply(null, arguments);}var s = createSomething(a,b,c); // 's' is an instance of Something
答案
.apply()
new
arguments
var createSomething = (function() { function F(args) { return Something.apply(this, args); } F.prototype = Something.prototype; return function() { return new F(arguments); }})();
白猪掌柜的
慕田峪7331174
相关分类