<script type="text/javascript"> var object = (function () { var variable = "test"; return { method: function (name) { alert( eval(name) ); } } })(); object.method( "variable" ); </script>