We all know about destructuring objects in ES6+
const myObject = {name: 'John', age: 30, eyeColor: 'brown'}
const {name, age, eyeColor} = myObject
... is there a "cleaner" way to do the following?
const name = 'John'
const age = 30
const eyeColor = 'brown'
myObject.name = name
myObject.age = age
myObject.eyeColor = eyeColor
Not a great example but in some cases I have to do this with 18 or so variables and it's ugly. Is there an elegant method or utility to do this?
Yea, you don't have to explicitly write out the value if the key and variable name are the same