fork download
  1. ob=function(arg){var prop=1, meth=function(x){return x+x;}, setp=function(x){prop=x;}; return eval(arg)};
  2. ob("setp(2)");
  3. console.log(ob("meth(prop)"));
  4.  
  5. ob = function() {
  6. var x = 1;
  7. return {
  8. meth: function() { return x + x; },
  9. setp: function(y) { x = y; }
  10. }
  11. }();
  12. ob.setp(2);
  13. console.log(ob.meth());
Success #stdin #stdout 0.06s 10928KB
stdin
Standard input is empty
stdout
2
4