Join Eve Porcello for an in-depth discussion in this video Destructuring assignment, part of Learning ECMAScript 6.
- Destructuring Assignment gives us an easy way…to extract data from arrays and objects and assign them…to variables.…First, let's take a look at how destructuring works…with arrays.…Here I have an array of cities, Spokane, Boston, LA,…Seattle and Portland.…And if I wanted to grab just the cities…that are in Washington, I could use cities 0…for the first one, and cities 3…to access this fourth item, zero, one, two, three.…Now this is a great way of handling this,…but let's update this to use destructuring.…
The first thing I want to do to do this is I'm going to…get rid of our cities here on eight and nine.…I'm also going to get rid of the cities variable name.…Instead, I'm going to replace this with an opening…and closing square bracket.…Now let's go ahead and pass in the name of some variables.…So these variables are going to stand in for…either Spokane, Seattle or whatever I'd like to pull…out of the array.…Now if I give this a shot, console log first,…and console log fourth,…we're going to see something interesting happen…
- What is ECMAScript?
- Transpiling ECMAScript with Babel and Babel-node
- Using the let and const keywords
- Creating strings with template strings
- Enhancing object literals
- Working with ES6 classes and class inheritance
Skill Level Beginner
Q: The Babel API is out of date. How do I proceed with the course?
A: We are updating the course. In the meantime, you can install the babel-cli package and then install the presets that you need to follow along with the tutorials.