user117829
user117829

Reputation: 566

What is the name of this feature in JavaScript?

Let say, we have a variable:

const name = 'bob';

I want to define an object with key-value pair that holds name as key and 'bob' as value. Then, I do this:

const obj = { name };

JavaScript automatically infers the key-value pair from the variable defined. How does JS do it and what is the name of this feature?

Upvotes: 2

Views: 80

Answers (1)

ic3b3rg
ic3b3rg

Reputation: 14927

These are called shorthand property names

Upvotes: 3

Related Questions