Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Assign keys to an object with the same name

let name = 'bob';let age = 34;let job = 'carpenter';// instead of thislet myObject1 = { name: name, age: age, job: job };// do thislet myObject2 = { name, age, job };console.log(myObject2);--> { name: 'bob', age: 34, job: 'carpenter' }
Source by levelup.gitconnected.com #
 
PREVIOUS NEXT
Tagged: #Assign #keys #object
ADD COMMENT
Topic
Name
7+2 =