Skip to content

Instantly share code, notes, and snippets.

@jasonbellamy
Created September 23, 2015 21:22
Show Gist options
  • Save jasonbellamy/fd8b603ff1fb3496f5a9 to your computer and use it in GitHub Desktop.
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.
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