When you are assigning keys to an object, if the key is the same name as the variable that holds the value you want to assign you can omit the value assignment altogether. This prevents you from having to repeat yourself, something we all hate doing. Let’s take a look at an example using some of the same data from our last example:
let name = 'bob';
let age = 34;
let job = 'carpenter';
// instead of this
let myObject1 = { name: name, age: age, job: job };
// do this
let myObject2 = { name, age, job };
console.log(myObject2);
--> { name: 'bob', age: 34, job: 'carpenter' }
Source
https://levelup.gitconnected.com/6-javascript-code-snippets-for-solving-common-problems-33deb6cacef3