1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
var res = 0; function foo(x, n, y) { for (var j = 0; j < n; j++) { x[j]; y.f; } } var x = [1,2,3,4,5]; var y = {}; Object.defineProperty(y, 'f', {get:function() { res++; x.length = 2; }}); var a = foo(x, 5, y); assertEq(res, 5);