testDirectProxySetArray4.js (706B)
1 // Assigning to an existing array element via a proxy with no set handler 2 // calls the defineProperty handler. 3 4 function test(arr) { 5 var p = new Proxy(arr, { 6 defineProperty(t, id, desc) { 7 hits++; 8 9 // ES6 draft rev 28 (2014 Oct 14) 9.1.9 step 5.e.i. 10 // Since the property already exists, the system only changes 11 // the value. desc is otherwise empty. 12 assertEq(Object.getOwnPropertyNames(desc).join(","), "value"); 13 assertEq(desc.value, "ponies"); 14 return true; 15 } 16 }); 17 var hits = 0; 18 p[0] = "ponies"; 19 assertEq(hits, 1); 20 assertEq(arr[0], 123); 21 } 22 23 test([123]); 24 test(new Int32Array([123]));