Skip to content

Instantly share code, notes, and snippets.

@obenjiro
Created January 3, 2014 13:56
Show Gist options
  • Save obenjiro/8238228 to your computer and use it in GitHub Desktop.
Save obenjiro/8238228 to your computer and use it in GitHub Desktop.
Live reload JS proof of concept
function outer(t){
for (var i = 0; i<3; i++){
function test(){return gl()();
var a = 1;
console.log(a + b);
}
console.log(test());
}
}
var f = true;
function getLatestVersion(){
var result = '';
if (f) result = 'var b = 2;\nt = 0;\nvar a = 2 + t;\ns=console.log.bind(console);console.log(a + b);';
else result = 's(1);return 2;';
f = false;
return result;
}
function gl(){
return eval( "(function(){" + getLatestVersion() + "})" );
}
outer(1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment