function add(x) { var sum = x; var tmp = function (y) { sum = sum + y; return tmp; }; tmp.toString = function () { return sum; }; return tmp; } alert(add(1)(2)(3)); //6 alert(add(1)(2)(3)(4)); //10不明白每次调用完都要运行toString,求高手分析下!
添加回答
举报
0/150
提交
取消