Destructuring
Destructuring assignment is a special syntax that allows us to “unpack” arrays or objects into a bunch of variables.
Array destructuring :
We should have an existing array at the right side, that we want to split into variables. The left side contains an array-like “pattern” for corresponding elements. It is shorter way of copying array items in to variables.
Example :
Object destructuring :
We should have an existing object at the right side, that we want to split into variables. The left side contains an object-like “pattern” for corresponding properties. Here, order does not matter but key name should be same as in the object.
Example :