In JavaScript, is there a shorter way to create object from a variable then below.
var d = 'something';
function map(d){
var obj = {};
obj[d] = d;
return obj;
}
well, the shortest looks like, but it is wrong as key is literal d
than its value.
function wrong(d){
return {d:d}
}
I don't mind the first version, but wonder any succinct way.
thanks.