Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Shorthand Properties in ES6

    John LindquistJohn Lindquist

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



    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


    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.