Javascript - Array Destructuring
Code Life
By Pierre Marsaa
Unpacking an Array
Imagine you have a team of three Codémon and you want each one in its own variable. The obvious way is to read them one index at a time:
↗️
Loading editor...
↶
↷
It works, but it's three lines that all say the same thing. Destructuring does it in one: you write the variable names inside brackets, on the left of the =.
↗️
Loading editor...
↶
↷
Verify