-2

Sorry that my title isn't very clear - didn't really know what else to call this.

Basically what I want to do is have a variable that is

"authData."+service+".displayName";

And turn that into

authData.theValueGivenToService.displayName;

Any idea on how to do that?

(I'm working with JavaScript/JQuery by the way - I should have mentioned that earlier)

Eli Yazdi
  • 25
  • 8
  • The question is not really clear to me, what's your goal? – emazzotta Jan 06 '16 at 20:29
  • Yeah, sorry I hadn't realized this had already been asked (I wasn't able to find anything for it). Should I just delete this one now? – Eli Yazdi Jan 06 '16 at 20:35
  • @Satpal I was just going to use it as shorthand for authData[service].displayName but I now realize that that's pointless – Eli Yazdi Jan 06 '16 at 20:36

1 Answers1

2

If you are trying to access a property of object then do:

displayName = authData[service].displayName;
void
  • 36,090
  • 8
  • 62
  • 107
  • A suggestion, Don't start answer with `if`, it shows you are making a guess better leave a comment for clarification. – Satpal Jan 06 '16 at 20:30
  • @Satpal that is okay, but my `if` was depicting that I am pretty sure what OP is asking but the way OP has choses is probably not the best way to write it down. But yes your suggestion, i got it. :) – void Jan 06 '16 at 20:32
  • @void It tells me "I can accept an answer in 5 minutes". I'm somewhat new here, so I have no idea why, but I'll mark it as answer when it lets me. Thank you so much for your help! :) – Eli Yazdi Jan 06 '16 at 20:37