new-read-before-write.js (420B)
1 function Foo() { 2 var x = this.property; 3 this.property = 5; 4 glob = x; 5 } 6 Foo.prototype.property = 10; 7 for (var i = 0; i < 10; i++) { 8 new Foo(); 9 assertEq(glob, 10); 10 } 11 12 function Bar() { 13 this.property; 14 this.other = 5; 15 } 16 Bar.prototype.other = 10; 17 Object.defineProperty(Bar.prototype, "property", { 18 get: function() { glob = this.other; } 19 }); 20 for (var i = 0; i < 10; i++) { 21 new Bar(); 22 assertEq(glob, 10); 23 }