Patternite Logo

Array destructuring in JavaScript

0

Some simple, commonly used patterns for destructuring JavaScript arrays

Loading...

By destructuring arrays, we can cleanly assign variables to array elements without having to write verbose, multi-line code such as the following:

a = myArray[0]
b = myArray[1]
c = myArray[2]

The MDN docs have a very thorough overview of array (and object) destructuring.

Profile picture for duncster

Patternite © 2021

Patternite Logo