Here's a quick Javascript tip. If you need to create a variable but won't know the name of the variable until runtime, here's a quick way to do it without using eval:
var foo = "wackyvariablename";
window[foo] = 123;
alert(wackyvariablename);
It also works for Javascript objects too:
var foo = "wackyvariablename";
var someobject = {};
someobject[foo] = 123;
alert(someobject.wackyvariablename);
Javascript - it's the new lisp.
Recent Comments