A number of JavaScript libraries these days, require strong understanding of the ES6 language. If you want to comfortably work with libraries like Redux, ReactJS, Relay, GraphQL it’s important to understand some of the latest concepts.
Here’s my second item in the series of articles with videos on the topics. The second topic is Array Destructuring, where we extract items from an array and assign to variables.
let numbers = [10,20,30] //Old style // let a = numbers[0] // let b = numbers[1] // let c = numbers[2] //ES2017 let [a,b,c] = numbers console.log(a,b,c); let [i,_,k] = numbers console.log(i,k); //Swapping two numbers var num1 = 100 var num2 = 200 var [num2,num1] = [num1,num2] console.log(num1,num2);
You can watch the video here