Syntax question about this example. Destructuring I believe?

I was doing some reading outside of FCC and came across this example. The line that is commented out is what I was expecting and I don’t understand how the other version works. I expect it’s some form of destructuring but not sure.

let list = [{ title: "Rad Red" }, { title: "Lawn" }, { title: "Party Pink" }];

const addColor = (title, array) => array.concat({ title });
//const addColor = (title, array) => array.concat({ title:title });

console.log(addColor("Glam Green", list));

In the line that is commented out I understand how the .concat method is passed in an object consisting of a key / value pair. The version that isn’t commented though derives that key / value pair info just from {title} which is the part that confuses me.

Do you mean the object property shorthand form?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#property_definitions

Yep! That’s it, I just couldn’t google up the name of what that technique was called.

Thank you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.