thisprop.js (370B)
1 // test getthisprop 2 3 var expected = "22,22,22,;33,33,33,;"; 4 var actual = ''; 5 6 function f() { 7 for (var i = 0; i < 3; ++i) { 8 actual += this.b + ','; 9 } 10 actual += ';'; 11 } 12 13 function A() { 14 this.a = 11; 15 this.b = 22; 16 }; 17 18 A.prototype.f = f; 19 20 function B() { 21 this.b = 33; 22 this.c = 44; 23 }; 24 25 B.prototype.f = f; 26 27 new A().f(); 28 new B().f(); 29 30 assertEq(actual, expected);