Javascript: Get access to local variable or variable in closure by its name [duplicate]

I’m not aware of anything built into JavaScript to reference local variables like that (though there probably should be considering all variables are internally referenced by strings). I’d suggest keeping all your variables in an object if you really need to access by string: var variables = { “j”: 1 }; alert(variables[“j”]); Update: It kind … Read more

jQuery code doesn’t work if I’m using a local jquery.js file, why?

It’s an encoding problem. Your page.html file is in UTF-16 (although it contains an erroneous meta tag saying that it’s using UTF-8), but the jquery.js file isn’t (it’s either in ASCII, Windows-1252/ISO-8859-1, or UTF-8 — doesn’t really matter which, it sticks to the characters all of them have in common). I suggest correcting the encoding of … Read more