Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Created November 24, 2021 19:10
Show Gist options
  • Save catwhocode/267630c6b3aba18a5798e18a8e2d8867 to your computer and use it in GitHub Desktop.
Save catwhocode/267630c6b3aba18a5798e18a8e2d8867 to your computer and use it in GitHub Desktop.
Destructuring Rest Parameter
// source:
// https://dev.to/sagar/three-dots---in-javascript-26ci
function myFunc(...[x, y, z]) {
return x * y* z;
}
myFunc(1) // NaN
myFunc(1, 2, 3) // 6
myFunc(1, 2, 3, 4) // 6 (fourth parameter is not destructured)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment