fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5.  
  6. ob=function(){
  7. var prop=1;
  8. return function(arg){
  9. var meth=function(x){return x+x;}, setp=function(x){prop=x;};
  10. return eval(arg)}}();
  11. ob("setp(2)");
  12. console.log(ob("meth(prop)"));
  13.  
  14. ob = function() {
  15. var x = 1;
  16. return {
  17. meth: function() { return x + x; },
  18. setp: function(y) { x = y; }
  19. }
  20. }();
  21. ob.setp(2);
  22. console.log(ob.meth());
  23.  
Success #stdin #stdout 0.06s 10968KB
stdin
Standard input is empty
stdout
4
4