How to use a js class attribute as a key in an array of another class attribute

I have a JavaScript class in which I have some attributes which are basically an enum (at least that’s what I would use in Java). Now I want to define names for each attribute and I thought I could just use JavaScript object notation as follows:

class CareerLevels {
    static manager    = 'manager';
    static consultant = 'consultant';
    static associate  = 'associate';
    static names = {
        manager    : 'Manager',
        consultant : 'Consultant',
        associate  : 'Associate Consultant',
    }
}

Now it turns out that the keys in the names-array are actually just the string representation of the variable name and not the above defined variable value. How can I make the code use the above defined variable values (since I simplified for the example, variable names and values are actually not always the same)?

I tried

class CareerLevels {
    static manager    = 'manager';
    static consultant = 'consultant';
    static associate  = 'associate';
    static names = {
        CareerLevels.manager    : 'Manager',
        CareerLevels.consultant : 'Consultant',
        CareerLevels.associate  : 'Associate Consultant',
    }
}

But that is not valid JavaScript. What am I missing? Is it not possible to define the variables in this way in JavaScript. Or how would be the correct way to do this? Ideally the variables would also all be constants, but I figured that this is not possible without much more boiler plate code that I would like to avoid.

Answer

You need to use computed property names:

static names = {
    [this.manager]    : 'Manager',
    [this.consultant] : 'Consultant',
    [this.associate]  : 'Associate Consultant',
}