Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of ES6 Rest Parameters
/* ES5 */
function catFight (action) {
var moreActions = Array.prototype.slice.call(arguments, 1);
return action + '! ' + moreActions.join('! ') + '!';
}
catFight('Slash', 'Hiss', 'Yowl');
// > 'Slash! Hiss! Yowl!'
/* >= ES6 */
function catFight (action, ...moreActions) {
return action + '! ' + moreActions.join('! ') + '!';
}
catFight('Slash', 'Hiss', 'Yowl');
// > 'Slash! Hiss! Yowl!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment