Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Created April 2, 2016 18:18
Show Gist options
  • Save tzmartin/d2028f6a5a82094ec28172d5ee8a63ef to your computer and use it in GitHub Desktop.
Save tzmartin/d2028f6a5a82094ec28172d5ee8a63ef to your computer and use it in GitHub Desktop.
js transform function
function Test() {
this.data = {
"foo":"bar"
};
}
Test.prototype.transform = function(str) {
var err = false;
var input = this.data;
var output = false;
try {
function run() {
eval(str);
return output;
}
output = run();
}catch(e) {
err = e;
}
console.log((err)?err:output);
//console.log(this.data);
}
var a = new Test();
a.transform('output = input');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment