letname ="W3Schools"; // Destructuring let[a1, a2, a3, a4, a5] = name; Try it Yourself » Note: Destructuring can be used with any iterables. Array Destructuring We can pick up array variables into our own variables: Example
Destructuring is exactly the same. We may have an array or object that we are working with, but we only need some of the items contained in these.Destructuring makes it easy to extract only what is needed.Destructing ArraysHere is the old way of assigning array items to a variable:...