Run details:
Mozilla/5.0 (X11; CrOS x86_64 14092.77.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.107 Safari/537.36
Chrome 93
Chrome OS 14092.77.0
Desktop
3 years ago
Test name Executions per second
String() 15198.2 Ops/sec
.toString() 175576.0 Ops/sec
template string 270942.2 Ops/sec
concat with string 272331.6 Ops/sec
Tests:
  • String()

    AخA
     
    let nums = [];
    for(let i = 0; i < 100; ++i) {
      nums.push(String(i));
    }
  • .toString()

     
    let nums = [];
    for(let i = 0; i < 100; ++i) {
      nums.push(i.toString());
    }
  • template string

     
    let nums = [];
    for(let i = 0; i < 100; ++i) {
      nums.push(`${i}`);
    }
  • concat with string

     
    let nums = [];
    for(let i = 0; i < 100; ++i) {
      nums.push(i + "");
    }