fork download
  1. var foo = (function ble() {
  2. var name = "bar";
  3. var obj = {};
  4.  
  5. obj.getName = function () {
  6. return name;
  7. };
  8.  
  9. obj.setName = function (newName) {
  10. name = newName;
  11. };
  12.  
  13. return obj;
  14. }());
  15.  
  16. console.assert(foo.name, undefined);
  17. console.assert(foo.getName(), "bar");
  18. foo.setName("baz");
  19. console.assert(foo.name, undefined);
  20. console.assert(foo.getName(), "baz");
Runtime error #stdin #stdout #stderr 0.43s 381888KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
js: uncaught JavaScript runtime exception: ReferenceError: "console" is not defined.