Created
May 2, 2018 20:55
-
-
Save sarahquigley/4768a9a4bef39db15a7cc0adf600ca3d to your computer and use it in GitHub Desktop.
Example of ES6 Rest Parameters - Arguments for Variadic Functions
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
/* ES5 */ | |
var actions = [ 'Slash', 'Hiss', 'Yowl']; | |
catFight.apply(undefined, actions); | |
// > 'Slash! Hiss! Yowl!' | |
/* >= ES6 */ | |
var actions = [ 'Slash', 'Hiss', 'Yowl']; | |
catFight(...actions); | |
// > 'Slash! Hiss! Yowl!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment