1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
function test() { var c = 0; for (var i=0; i<20; i++) { var arr = [1]; if (i > 5) Object.defineProperty(arr, "length", { writable: false, value: 4 }); try { arr.push(2); } catch(e) { assertEq(e.toString().includes("length"), true); c++; } } assertEq(c, 14); } test();