Skip to content

Instantly share code, notes, and snippets.

@joeegan
Created September 5, 2017 10:36
Show Gist options
  • Save joeegan/3dc3de7e2853296e3d2201fe8e234c04 to your computer and use it in GitHub Desktop.
Save joeegan/3dc3de7e2853296e3d2201fe8e234c04 to your computer and use it in GitHub Desktop.
restArgs & spread clarification
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