const key1 = "name"; const key2 = "age"; const student = { [key1]:"john Doe", [key2]:26 } console.log(student) //{ name:"john Doe", age:26 }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter