Is it at all possible to re-implement ‘function’ or ‘eval’ in pure javascript? E.g. lets say I wanted to be able to write the following:
// note that I don't want to have to put code in a string here
var x = func() { var something = "nothing"; return something; }
or
var hiString = 'hi' // note that it of course needs to be able to access the current context
evaluatize("function hi(){ alert(hiString); } hi();")
Are either of these things possible in javascript?
No, it is not possible to do this.