I usually program in Python, but today I was trying to reverse engineer some Javascript code and I came across this line:
var ABC = DEF[XYZ];
DEF is a function that was defined earlier. It takes one argument. XYZ is a string that was created earlier, and it contains the results of running DEF previously.
I don't know much JavaScript, but it seems to me like it is defining a variable called ABC that contains the results of running function DEF with the argument XYZ. However, later on there is a line that goes var GHI = ABC(JKL, DEF(MNO)) (JKL and MNO are both variables defined earlier).
What puzzles me is that ABC was defined as a variable, not a function. So I'm thinking this has something to do with the square brackets seen earlier.
So my question is: what is the purpose of those square brackets?
DEFis not a function, pretty sure. Can you show the source ofDEF? You need to show us the context. If you can't link the exact code, cut it down and make one that behaves similarly.[...]is used to get a property of an object. Sovar XYZ = "call"; var ABC = DEF[XYZ];is the same asvar ABC = DEF.call