From: Marcus Andersson Date: 2006-05-18T16:06:42+09:00 Subject: Re: Is there an equivalent to instance_eval in JavaScript? No, I don't think so. But you can probably add it. Object.prototype.instance_eval = function(code_or_function) { var func = null; if(typeof(code_or_function) == "function") { func = code_or_function; } else if(typeof(code_or_function) == "string") { func = function() { eval(code_or_function); } } if(func) { return func.apply(this); } } var o = { helloPhrase : "hello" }; o.instance_eval(function() { alert(this.helloPhrase); }); o.instance_eval("alert(this.helloPhrase);"); Although you might not want to add it to Objects prototype and do it as a function that takes the receiving object as a parameter. I'm also not 100% sure that this captures the full semantics of instance_eval altough I guess it's quite close. /Marcus