1

I am trying to create a javascript object inside of a helper method. What I am trying to accomplish is basically create a map so key=value. here is the code I have

var tabVariables = {
    0 : $A.get("$Label.c.UX_APPLIED_CC"),
    1 : $A.get("$Label.c.UX_SAVED"),
    2 : $A.get("$Label.c.UX_DIRECT"),
    $A.get("$Label.c.UX_APPLIED_CC") : 0
};

The first three lines work fine. the 4th line $A.get("$Label.c.UX_APPLIED_CC") : 0 gives me an error "Unexpected token .". Any idea if it is possible to do this with the label?

1 Answer 1

0

No, if you use the object constructor notation, you can't do this. However, you can set it immediately afterwards.

tabVariables[$A.get("$Label.c.UX_APPLIED_CC")] = 0;
1
  • Thank you that was exactly what I needed.
    – Travis
    Commented Jun 18, 2019 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .