Created
September 23, 2015 21:22
-
-
Save jasonbellamy/fd8b603ff1fb3496f5a9 to your computer and use it in GitHub Desktop.
Using the ..spread operator gives us a proper array from the start and lets us stop using the arguments object.
This file contains hidden or 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
var square = function(...args) { | |
return args.map(function(arg) { | |
return arg * arg; | |
}); | |
}; | |
square(1, 2, 3, 4, 5); // => [1, 4, 9, 16, 25] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment