I have an object that I want to initialize with dynamically named keys. I know I can do it in code like this:
obj = {};
prefix = "blah";
i = 0;
obj[prefix + i] = "whatever";
console.log( obj.blah0 );
e.g. like from here: How do I create a dynamic key to be added to a JavaScript object variable
But can this be done in an initializer?
obj = { [prefix+i]: "whatever" };
I know that doesn't work. I tried it. But is there a similar method that does work?