Skip to content

Instantly share code, notes, and snippets.

@Bwogi
Created December 2, 2021 00:33
Show Gist options
  • Select an option

  • Save Bwogi/6bd8faad81c6dc881e1a7d5c0c5a0733 to your computer and use it in GitHub Desktop.

Select an option

Save Bwogi/6bd8faad81c6dc881e1a7d5c0c5a0733 to your computer and use it in GitHub Desktop.
Destructuring explained

destructuring explained

The syntax also works on arrays:

const a = [1, 2, 3, 4, 5]
const [first, second] = a

This statement creates 3 new variables by getting the items with index 0, 1, 4 from the array a:

const [first, second, , , fifth] = a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment