0

Someone can explain the difference between

$(data.selector)[data.action]

and :

$(data.selector).data.action

data.selector and data.action are two string

Cliffe
  • 107
  • 1
  • 9
  • 1
    In the first snippet `data.action` needs to be a string or number, in the second snippet it can be anything – Teemu Oct 10 '17 at 07:46
  • @Teemu: There's absolutely no relation between the `data.action` in both examples, aside from them being written using the same letters. – Cerbrus Oct 10 '17 at 07:46
  • @Cerbrus Did I say there should? – Teemu Oct 10 '17 at 07:47
  • Kinda, you implied that in the second snippet, `data.action` is something. It's not. `data.action` on its own there should throw an error. – Cerbrus Oct 10 '17 at 07:48
  • Why there should be an error? It's just an expression, like a lonely number on a line, the return value is just not used anywhere. Like I said (or rather you did), it has to refer something, if it doesn't, then an error occurs. – Teemu Oct 10 '17 at 07:49

0 Answers0