JSFiddle - React, Tailwind, and code Playground
JavaScript
// Originally from http://jsfiddle.net/danShumway/5zwFv/
Function.snapshotFunction = function(one, two){
for(var i = 0; i < two.length; i+=2){
eval("var " + two[i] + " =two[i + 1]");
}
eval("var toReturn = " + one);
return toReturn;
}
function Duck() {
this.quackStr = "kwaq";
this.doQuack = Function.snapshotFunction(function() { snapQuack(); }, ["snapQuack", function() { console.log(this.quackStr); }]);
this.realDoQuack = function() { console.log(this.quackStr); };
}
this.quackStr = "I AM A WINDOW, NOT A DUCK!!!";
(new Duck()).doQuack();
(new Duck()).realDoQuack();