This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    Shorthand Properties in ES6

    John LindquistJohn Lindquist

    Shorthand properties allow you to compose complex objects from other objects.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    John Lindquist: 00:02 Where destructuring in ES6 allows you to easily get properties out of an object, this shorthand property syntax allows you to easily push properties in. It's like destructuring backwards.

    00:11 If I have a first name and a last name and I want to create a person, I can just say, "firstName, lastName." Then when I log out my person and I run this, you can see that it logs out an object with the first name of John and a last name of Lindquist.

    00:29 If I wanted to build some more objects, like I want to build a team. I have a mascot with a Moose, and I wanted to build a team like this, where I have a person and a mascot, and then I log out my team. I have a team object with a person of "firstName, lastName," John and Lindquist, with the mascot of moose.

    00:53 This syntax allows you to easily construct objects with the properties and things you already have and just build them up however you'd like.

    Discuss

    Discuss