Destructuring Assignment in ES6- Arrays
Destructuring assignment is a cool feature that came along with ES6. Destructuring is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. That is, we can extract data from arrays and objects and assign them to variables. Why is this necessary? Imagine if we want extract a data from an array. Previously, how will this be done? var introduction = ["Hello", "I" , "am", "Sarah"]; var greeting = introduction[0];// here we r assigning greeting key to above value var name = introduction[3]; console.log(greeting);//"Hello" // outputing console.log(name);//"Sarah" We can see that when we want to extract data from an array , we had to do the same thing over and over again. ES6 destucturing assignment makes it easier to extract this data. How is this so? This article discusses destructuring assignment of arrays. My next article...