const sample= {
[name]:value
}
What exactly the above JavaScript object represents
const sample= {
[name]:value
}
What exactly the above JavaScript object represents
This means name is variable
like
let name = 'John';
const sample= {
[name]:value
}
So sample will be like this
sample.John = value
Try this
let name = 'John';
const sample= {
[name]:"I am John"
}
console.log(sample);