michael@0: // A for-of loop over an array does not take a snapshot of the array elements. michael@0: // Instead, each time the loop needs an element from the array, it gets its current value. michael@0: michael@0: var a = [3, 5, 5, 4, 0, 5]; michael@0: var s = ''; michael@0: for (var i of a) { michael@0: s += i; michael@0: a[i] = 'X'; michael@0: } michael@0: assertEq(s, '355X0X');