Basically what I am after is this,
var foo = 'I am foo!';
alert(window['foo']);
// output = I am foo!
This does not work in a jQuery wrapper, I understand that it may be due to jQuery having renamed the window object or whatnot. If anyone has any inkling as to if this may be possible in a jQuery wrapper, I would appreciate the knowledge !
If you have a function scope around your
varline, it’ll define it as a local variable instead of a global variable. It’s not jQuery “renaming the window object” or anything silly like that, it’s just howvarworks. I’d personally doingthough, to make it explicit you wanted to define a global variable. Or use a comment to say that.