Grokking Advanced JavaScript
0% completed
Destructuring Assignment
Copying values out of an array or an object into separate variables is a frequent task in everyday code. The traditional way takes one line per value, and each line repeats the name of the array or object.
The car in this lesson has a paint color stored as three numbers for red, green, and blue. Reading them one at a time looks like this:
255 0 0
The three lines differ only in a variable name and an index, and an index typed wrong would go unnoticed until the color looks wrong. Destructuring assignment is a syntax that writes the shape of the data on the left side of `=
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%