Languages
[Edit]
EN

JavaScript - unpack array elements into separate variables

0 points
Created by:
Kevin
797

In this article, we would like to show you how to destructure (unpack) array elements into separate variables in JavaScript.

1. Using array notation

Edit

In this section, we use simple array notation to "unpack" array into separate variables by index.

2. Using ES6 destructuring assignment

Edit

In this section, we use array destructuring to unpack array items into separate variables by index.

Example 1

Edit

Example 2

Edit

 

See also

Edit
  1. JavaScript - array destructuring with rest parameter

References

Edit
  1. Destructuring assignment - JavaScript | MDN

Alternative titles

  1. JavaScript - unpacking array elements into separate variables
  2. JavaScript - destructure array elements into separate variables
  3. JavaScript - destructuring array elements into separate variables
  4. JavaScript - assign array values to multiple variables
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join