在‘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);
}})();
一只名叫tom的猫
白猪掌柜的
慕田峪7331174
随时随地看视频慕课网APP
相关分类