Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Created November 24, 2021 19:16
Show Gist options
  • Select an option

  • Save catwhocode/47b132182e31f028a8d2e4e4f6694a6f to your computer and use it in GitHub Desktop.

Select an option

Save catwhocode/47b132182e31f028a8d2e4e4f6694a6f to your computer and use it in GitHub Desktop.
Using Spread Operator in Javascript
// source:
// https://dev.to/sagar/three-dots---in-javascript-26ci
function myFunc(x, y, ...params) { // used rest operator here
console.log(x);
console.log(y);
console.log(params);
}
var inputs = ["a", "b", "c", "d", "e", "f"];
myFunc(...inputs); // used spread operator here
// "a"
// "b"
// ["c", "d", "e", "f"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment