tor-browser

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

store-element-hole-sparse-element.js (595B)


      1 function test() {
      2  Object.defineProperty(Array.prototype, 10_000 * 50, {
      3    set() {
      4      throw new Error("shouldn't get here");
      5    }
      6  });
      7 
      8  // A bunch of indices which grow the array.
      9  var indices = [];
     10  for (var i = 0; i < 10_000; ++i) indices.push(i);
     11 
     12  // And finally an index for a sparse property.
     13  indices.push(10_000 * 50);
     14 
     15  // Plain data properties use DefineDataProperty.
     16  var desc = {value: 0, writable: true, enumerable: true, configurable: true};
     17 
     18  var a = [];
     19  for (var i = 0; i < indices.length; ++i) {
     20    Object.defineProperty(a, indices[i], desc);
     21  }
     22 }
     23 
     24 test();