Skip to content

Instantly share code, notes, and snippets.

@yangsu
Created January 29, 2013 21:20
Show Gist options
  • Save yangsu/4667982 to your computer and use it in GitHub Desktop.
Save yangsu/4667982 to your computer and use it in GitHub Desktop.
JavaScript Arguments
function sumParams () {
var actualArrayOfArgs = Array.prototype.slice.call(arguments),
sum = 0;
actualArrayOfArgs.forEach(function (arg) {
sum += arg;
});
return sum;
}
sumParams(1, 2, 3); // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment