tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

for-in-densified-elements.js (503B)


      1 function test() {
      2    // An array with sparse elements...
      3    var arr = [];
      4    arr[10_000] = 1;
      5    arr[10_001] = 1;
      6 
      7    for (var prop in arr) {
      8        assertEq(prop, "10000");
      9        assertEq(arr.length, 10_002);
     10 
     11        // Densify the elements.
     12        for (var i = 0; i < arr.length; i++) {
     13            arr[i] = 1;
     14        }
     15 
     16        // Delete the last dense element (10001). It should not be visited by the
     17        // active for-in (checked above).
     18        arr.length = 10_001;
     19    }
     20 }
     21 test();