1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
var o = { }; for (var i = 0; i <= 50; i++) o[i] = i; Object.defineProperty(o, "51", { get: assertEq }); var threw = 0; function g(o, i) { try { assertEq(o[i], i); } catch (e) { threw++; } } function f() { for (var i = 0; i <= 51; i++) g(o, i); } f(); f(); f(); assertEq(threw, 3);