Hi today I am going to show you how to destructure an array in JavaScript.
Let's take an object.
This is how we retrieve the values of arrays normally in a very simple way.
But can do the same in a line using array destructuring.
Now taking we can use the values of restaurant using array destructuring.
Suppose we want to take categories . We can do it like this.
Suppose we don't want all the values in category
then
Top comments (1)
Array destructuring is good for
for
loops:And there's object destructuring (which can have nesting of terms):
It is handy in loops as well.
Also, it can be used in parameter lists.
P.S.
Could you rather use code blocks instead of/as well as "screenshots"? The "screenshots" look nice, but you can't copy-paste code from them. For this it isn't really an issue, but for anything longer it can be nice to be able to if someone wants to just copy it and test it out.