tor-browser

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

regular-subclassing.js (764B)


      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: 20.1.1
      5 description: Subclassing the Number object
      6 info: |
      7  20.1.1 The Number Constructor
      8 
      9  ...
     10 
     11  The Number constructor is designed to be subclassable. It may be used as the
     12  value of an extends clause of a class definition. Subclass constructors that
     13  intend to inherit the specified Number behaviour must include a super call to
     14  the Number constructor to create and initialize the subclass instance with a
     15  [[NumberData]] internal slot.
     16 ---*/
     17 
     18 class N extends Number {}
     19 
     20 var n = new N(42);
     21 
     22 assert.sameValue(n.toFixed(2), '42.00');
     23 assert.sameValue(n.toExponential(2), '4.20e+1');
     24 
     25 reportCompare(0, 0);