Skip to content

Instantly share code, notes, and snippets.

@userkang
Created January 17, 2019 07:25
Show Gist options
  • Save userkang/9fcc919d6749db63c613b88540aa6023 to your computer and use it in GitHub Desktop.
Save userkang/9fcc919d6749db63c613b88540aa6023 to your computer and use it in GitHub Desktop.
一直加下去
function add() {
var sum = 0;
function add() {
for (var i=0; i<arguments.length; i++) {
sum += Number(arguments[i]);
}
return add;
}
add.valueOf = function valueOf(){
return sum;
};
return add.apply(null,arguments);
}
add(1,2)(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment