Destructuring Arrays to Extract Values in Javascript


Unpack values from arrays into distinct variables.

Source Code

let colors = ["red", "green", "blue"];
let [firstColor, secondColor] = colors;
console.log(firstColor); // "red"
console.log(secondColor); // "green"
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments