tor-browser

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

string-substring-is-charat-end.js (325B)


      1 // |str.slice(-1)| and |str.substr(-1)| are compiled as |str.at(str.length - 1)|.
      2 
      3 const strings = [
      4  "",
      5  "a", "b",
      6  "ab", "ba",
      7 ];
      8 
      9 for (let i = 0; i < 1000; ++i) {
     10  let str = strings[i % strings.length];
     11 
     12  assertEq(str.slice(-1), str.charAt(str.length - 1));
     13  assertEq(str.substr(-1), str.charAt(str.length - 1));
     14 }