I’ve been using both in javascript … really don’t know the difference. Googling always shows results for the “window object” or “opening a new window in javascript” so couldn’t find anything there.
eval("v"+e)
window["v"+e]
Sometimes window works for me and at other times eval works ….
So what’s the difference between eval() and window[] ?
Sorry for the newbie question though !
Norman
Another point that has not been addressed is that
evalwill resolve the variable reference using the caller variable environment, for example:So as you can see, is not completely equivalent.
If you simply want to reference a global variable, I would recommend you to use the
window[prop]approach and avoid surprises.