tor-browser

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

defaults-destructuring-with-rest.js (578B)


      1 load(libdir + "asserts.js");
      2 load(libdir + "eqArrayHelper.js");
      3 
      4 function f1(a, bIs, [b]=[3], ...rest) {
      5    assertEq(a, 1);
      6    assertEq(bIs, b);
      7    assertEqArray(rest, []);
      8 }
      9 assertEq(f1.length, 2);
     10 f1(1, 3);
     11 f1(1, 42, [42]);
     12 
     13 function f2([a]=[rest], ...rest) {
     14    assertEq(a, undefined);
     15 }
     16 // TDZ
     17 assertThrowsInstanceOf(f2, ReferenceError);
     18 
     19 function f3([a]=[rest], ...rest) {
     20    assertEq(a, 1);
     21    assertEqArray(rest, [2, 3, 4]);
     22 }
     23 // TDZ
     24 assertThrowsInstanceOf(f3, ReferenceError);
     25 
     26 function f4([a]=rest, ...rest) {
     27 }
     28 // TDZ
     29 assertThrowsInstanceOf(f4, ReferenceError);