var add = function(x,r) {
if(arguments.length == 1){
return function(y) { return x + y; };
}else{
return x+r;
}
};
console.log(add(2)(5));
console.log(add(2,5));
控制台输出测试:
7,
7