ECMAscript 6 destructuring provides flexible options for variable assignment.
Destructuring is a shortcut syntax. Assignment of Skyler to Skyler object forced me to rewind.
Is destructuring often used in modules import ? e.g. import { XX } from 'xxx/core' ?
Hi, it is a pity that you mix old ECMA 5 and ECMA 6 script together in every session of the course "Learn ES6 (ECMAScript 2015)". So it would be nice to just use "let" instead of "var" always. And for sure some the other stuff you very nicely introduce. So would would have a much better learning effect.
But I love your way of introducing things in short videos.
At about the two minute mark, when you use state:location the state becomes part of your url on reload. The page returns a file not found error as es6/index.html becomes es6/New%20York. So location is a keyword to be avoided.
Code in transcript is wrong.
var [,Skyler] = people;
Should be:
var [Skyler,] = people;
Great examples. Your videos are one of the reasons I subscribe to Egghead.
Hi, I am playing around with the examples. Just wanted to add a second parameter to the arrow function inside like:
people.forEach(({firstName},{lastName}) => {
console.log(firstName) || displayInPreview(firstName);
console.log("lastName",lastName || displayInPreview(lastName));
})
But I get undefined for the lastName. Any ideas to display there other parameters? Thanks!
I like the Skyler example at the end as it combines a few concepts - the downside of course is it assumes the order of objects in the array won't change. For that reason I'd just use .find() and then perhaps de-structure the response as needed.
Hi Lluís Peinado, If you put lastName just next to firstName then it works.
people.forEach(({firstName, lastName}) => {
console.log(firstName) || displayInPreview(firstName);
console.log("lastName",lastName || displayInPreview(lastName));
})