Simplest self-modifying function in JavaScript?

This might not be a great solution, but hope it helps.

function selfm(str){
 this.print = eval("(function a() {"+str+"})") ;
 this.print();
} 

And you can then call onto with whatever string parameter you wish your function to act as.

selfm("console.log('Hello');");
// will print Hello in console.

selfm("alert('Hello');");
// will alert Hello

Still need to test on different browsers. :)