Reputation: 566
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