Created
January 29, 2013 21:20
-
-
Save yangsu/4667982 to your computer and use it in GitHub Desktop.
JavaScript Arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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