Happy Holidays to all. I'm trying to execute a function that I have saved in a variable, as I could do this?
I tried this.
funcVar = 'function (a, b) {c = a + b; alert (c);}';
document.write (funcVar);
but has no functionality, I want to use that function that is in the variable at some point.
eval, but... what's the actual usecase? In other words, why do you think you want to do this?evalis your friend, it works for all things, just doeval(funcVar)and you're golden.evalis not your friend.evalis slow, hard to debug, and causes more problems than it solves. It solves almost no problems that can't be solved better with another technique.evalis your friend that drinks all your beer and vomits on your couch. With friends like those...