Get value of bar by using foo variable

by podlipensky

JavaScript

var foo = "bar";
var bar = "foobar";
document.write(eval(foo));
document.write('</br>');

var f = new Function('return ' + foo);
document.write(f()); //work but only in simple local .html file (don't trust jsfiddle.com!)
document.write('</br>');

window.setTimeout('function(){document.write(' + foo + ')}', 0);//work but only in simple local .html file (don't trust jsfiddle.com!)