function add(x,y){ var sum = x; if(y) return sum+y; else { var temp = function(z){ sum = sum+z; return temp; } temp.toString = function () { return sum; }; return temp; } } console.log(add(2,3)); console.log(add(2)(3)(6));
转载于:https://www.cnblogs.com/TiffanyHYY/p/7661155.html