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?

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;
  • Thank you that was exactly what I needed. – Travis Jun 18 '19 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.