ES6 Destructuring

Using this feature values can be assigned to variables by matching patterns in an array or object. This is fail-soft, so if match fails, a variable will be initialized as undefined


In the last two examples above undefined is coming for b and z as there are no matching values. A default value can be given using = operator as shown below

Share