I would like to know if there is a clean way to set the key value from a string variable when using distribution syntax in es6?
Something like the following:
let keyVar = 'newKey'
let newObject = {keyVar:{some:'json'},...oldObject}
But this leads to:
{"keyVar":{"some":"json"}, ... }
but not:
{"newKey":{"some":"json"}, ... }
source
share