tor-browser

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

regular-subclassing.js (805B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 es6id: 23.1.1
      5 description: Subclassing the Map object
      6 info: |
      7  23.1.1 The Map Constructor
      8 
      9  ...
     10 
     11  The Map constructor is designed to be subclassable. It may be used as the
     12  value in an extends clause of a class definition. Subclass constructors that
     13  intend to inherit the specified Map behaviour must include a super call to the
     14  Map constructor to create and initialize the subclass instance with the
     15  internal state necessary to support the Map.prototype built-in methods.
     16 ---*/
     17 
     18 class M extends Map {}
     19 
     20 var map = new M([{ 'foo': 'bar' }]);
     21 
     22 assert.sameValue(map.size, 1);
     23 
     24 map.set('bar', 'baz');
     25 
     26 assert.sameValue(map.size, 2);
     27 
     28 reportCompare(0, 0);