Have you ever had the problem where you just want to assign elements of an array to individual variables (different from using the spread operator in the function arguments) or just have to use two keys of an object, which actually contains multiple keys? You’ll have to use a for loop to achieve the first objective and two new variables to achieve the second one if you try to achieve this using ES5. In ES6, you can do this very easily. Let’s see how.
In the last video, you learned how to destructure arrays and how to assign each element to an individual variable. But what about objects? Well let’s learn how to destructure objects in the next video.
Well that’s quite easy. Destructuring is a major blessing when you are required to use just some elements of an object or an array.