Function.prototype.times = function(val){
var that = this;
return function (arg) {
if(val == 0){
return that.call(this,arg);
}
else{
var newArg = that.call(this,arg);
var newVal = val - 1;
return that.call(that.times,newVal,newArg);
}
}
}
var add_two = function (num) { return num + 2; };
var add_six = add_two.times(3);
alert(add_six(2));
有人可以帮我解释为什么这段代码不起作用吗?谢谢!