function add(x) {
var sum = x;
var tmp = function (y) {
sum = sum + y;
return tmp;
};
tmp.toString = function () {
return sum;
}
alert(add(1)(2)(3)); //6
alert(add(1)(2)(3)(4)); //10
不明白每次调用完都要运行toString,求高手分析下!
相关分类