C
conzett
I have the name of an object in the form of a string. Is there a way
to access it as an object without eval? basically can I do this:
function foo(){
this.bar = function(){
alert("test")
}
}
var myFoo = new foo();
var examplVar = "myFoo";
eval(examplVar).bar();
//it alerts test
without having to use eval?
Sorry if this is a noob question I don't usually use javascript.
to access it as an object without eval? basically can I do this:
function foo(){
this.bar = function(){
alert("test")
}
}
var myFoo = new foo();
var examplVar = "myFoo";
eval(examplVar).bar();
//it alerts test
without having to use eval?
Sorry if this is a noob question I don't usually use javascript.