我想知道动态扩展Function的原型是不好的做法.我正在考虑使用静态方法来执行此操作,该方法接收属性名称和要添加到原型的函数.
这是一种不好的做法吗?
function Test() {
this.condition = false;
}
Test.extend = function(id, task) {
this.prototype[id] = function() {
return task.apply(this, arguments);
};
};
Run Code Online (Sandbox Code Playgroud)