1 // Copyright 2014 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 var array = []; 6 var v = 0; 7 8 Object.defineProperty(Array.prototype, "0", { 9 get: function() { return "get " + v; }, 10 set: function(value) { v += value; } 11 }); 12 13 array[0] = 10; 14 assertEquals(0, array.length); 15 assertEquals(10, v); 16 assertEquals("get 10", array[0]); 17 18 array.push(100); 19 assertEquals(1, array.length); 20 assertEquals(110, v); 21 assertEquals("get 110", array[0]); 22