1.

What are default parameters in ES6?

Answer»

 Destructuring is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct VARIABLES. You can also HANDLE nested structure by using nested destructuring syntax.

Object Destructuring
Consider the old way to assign variable to Object properties WITHOUT destructuring.

Now we will refactor the above using “Object Destructuring”. Basically, you use an object literal on the left-hand-side of an assignment expression for object destructuring.

Nested Object Destructuring
If there is nested object as in below case, we can destructure it by adding it’s value to ANOTHER object syntax 

Array Destructuring
Let’s FIRST see how to do it without destructuring. Here we use the index to assign the variables.

 Array destructuring is similar to object destructuring, but here instead of keys you assign any variable.

Skipping Items
It is possible to skip items in array destructuring by omitting items with comma(,).



Discussion

No Comment Found