function SomeFunc()
{
this.var1 = 123;
this.evalStr = "console.log('myvar:' + this.var1)";
}
var sf = new SomeFunc();
eval(sf.evalStr); // returns "myvar: undefined"
I'd like eval to take into account variables on my instantiated object, how can I do this?
EDIT: that question you marked as duplicate is way more complex than what I'm asking. I'm talking about evaling a string here.
EDIT: hey my question shouldn't get downvoted just because I dared to say "eval". sheesh. if you look down you'll see the answers are quite useful.