Another 4 JavaScript tips for shorter code | by Abhinav VP | Nov, 2021 | Medium

PHOTO EMBED

Wed Dec 01 2021 17:05:39 GMT+0000 (UTC)

Saved by @MattMoniz #object #javascript

const key1 = "name";
const key2 = "age";
const student = {
    [key1]:"john Doe",
    [key2]:26
}
console.log(student)
//{ name:"john Doe", age:26 }
content_copyCOPY

allows you to use object key as variable.

https://medium.com/@abhinav_vp/another-4-javascript-tips-for-shorter-code-64791c1111b4