fork(1) download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5.  
  6. var console = {
  7. log: function(s) {
  8. process.stdout.write(s+"\n");
  9. },
  10. };
  11.  
  12. function Foo() {
  13. this.readOnly = false;
  14. Object.defineProperty(this, "disabled", {
  15. get: function () { return !this.readOnly; },
  16. enumerable: true,
  17. });
  18. }
  19.  
  20. Foo.prototype.report = function (s) {
  21. console.log(s);
  22. for (var i in this) {
  23. if (typeof this[i] === "function")
  24. continue;
  25. console.log("\t" + i + " = " + this[i]);
  26. }
  27. }
  28.  
  29. var xxx = new Foo();
  30.  
  31. xxx.report("before:");
  32. xxx.readOnly = true;
  33. xxx.report("after:");
  34.  
  35. xxx.disabled = true;
  36. xxx.report("disabled = true; ... ?");
  37.  
  38.  
Success #stdin #stdout 0.06s 11184KB
stdin
Standard input is empty
stdout
before:
	readOnly = false
	disabled = true
after:
	readOnly = true
	disabled = false
disabled = true; ... ?
	readOnly = true
	disabled = false