function tco(f) {
var value;
var active = false;
var accumulated = [];
return function accumulator() {
accumulated.push(arguments);
if (!active) {
active = true;
while (accumulated.length) {
value = f.apply(this, accumulated.shift());
console.log(value)
}
active = false;
return value;
}
};
}
var sum = tco(function (x, y) {
if (y > 0) {
return sum(x + 1, y - 1)
} else {
return x
}
});
console.log(sum(1, 3))
请问一下变量 value (不是最后一次的时候)为什么会等于undefined
芜湖不芜
相关分类