distructuring array js code example
Example 1: unpack array into variables javascript
var yourArr = [1, 2, 3]
[one, , three] = yourArray // 2 is ignored
// one == 1 && three == 3
Example 2: destructuring es6 freecodecamp
const iceCreamFlavors = ['hazelnut', 'pistachio', 'tiramisu'];const flavor1 = iceCreamFlavors[0];const flavor2 = iceCreamFlavors[1];const flavor3 = iceCreamFlavors[2];console.log(flavor1, flavor2, flavor3);