This course will be retired on October 31, 2026.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Introducing ES2015!
You have completed Introducing ES2015!
Preview
Destructuring lets you break apart an array or object into variables. Watch this video to see for yourself just how easy it is.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Destructuring lets you
extract values from arrays or
0:00
objects then assign those
values to distinct variables.
0:03
Let me demonstrate in this code and
0:06
you can follow along by opening
the workspace for this video.
0:08
So in the file, destructuring-object.js,
0:11
I have a toybox object
with three items in it.
0:14
Using destructuring,
I can store the values of item1 of and
0:19
item2 in a new variable and
log item1 to the console.
0:23
So when I run this file in the console,
you see that it logs the value car.
0:29
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up