I was trying to create an object, where it would be nice (and save me some typing and duplication), if I could reference the value's key name inside the declaration, e.g. something like below:
const object = {
"keyNameA": doSomething(`${this values' key name}`), //i.e. doSomething("keyNameA")
"keyNameB": doSomething(`${this values' key name}`) //i.e. doSomething("keyNameB")
}
Question is: Is that something that can be achieved in JS with an object literal declaration?
Thank you in advance!
(I know that with a constructor function you can probably achieve the above, this is mainly about the question, if it is possible via object literal as well, somehow)