Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![gerardo keys](https://secure.gravatar.com/avatar/c416ba0ca327ecba543571279a9e3452?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
gerardo keys
14,292 PointsCan you explain a little more how this code part works?
return {...profile, craft};
I do understand how a spread operator operator works but don't really understand this simplified way of creating an object. Doesn't an object need a key-value pair? All I can see here is that you are creating an object with an array of the profile objects and another property I'm assuming is a reference to person.craft. I don't understand how this becomes an object and especially how its getting the person.craft property with just using craft...
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe spread operator expands the "profile" object into key/value pairs. Then the braces around the expression enclose those key/value pairs into a new object, including the additional property "craft".
And "craft" is a shorthand notation used for object literals. When the variable name is the same as the key, then the key need not be explicitly specified.
![Brian Wright](https://uploads.teamtreehouse.com/production/profile-photos/11595827/micro_WIN_20210521_10_58_36_Pro.jpg)
Brian Wright
6,770 PointsThe craft variable added is a shorthand way of writing { craft: craft}. When you add a key to an object which has the same name as the value you can simply write {craft}.
gerardo keys
14,292 Pointsgerardo keys
14,292 PointsOk im starting to get it now, I misunderstood the spread operator, I thought it only spread into arrays. Knowing that you can also use the shorthand for adding properties also made it easier to understand now. Thank you for the explanation!
ALMEKDAD ALMUHAMMAD
Courses Plus Student 10,947 PointsALMEKDAD ALMUHAMMAD
Courses Plus Student 10,947 PointsSteven Parker, please I did not understand that. could you please describe that in another way. what is "profile" and why we added it after ... and then we put "craft"??
Steven Parker
230,688 PointsSteven Parker
230,688 PointsThe example is from line 12 seen in the video about 5 minutes in. The "profile" is the parameter passed to the function (by the call to "then" on line 11) which contains the decoded response from the previous "then". And "craft" is a local variable created on line 8. So this line joins them together to create a larger object.