Created
September 5, 2017 10:36
-
-
Save joeegan/3dc3de7e2853296e3d2201fe8e234c04 to your computer and use it in GitHub Desktop.
restArgs & spread clarification
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
const stringify = (a, b) => | |
toString(a + b); | |
const init = (a, b) => // anti pattern | |
stringify(...[a, b]) // stringify(a, b) | |
const init = (...args) => | |
stringify(...args) | |
const init = (a, b) => | |
stringify(...arguments) // Not optimal in babel | |
const init = (...args) => { // put my args into an array | |
const [a, b] = args; // likely to want this | |
return stringify(...args) // explode my array into comma list | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment