toString vs String() vs left implicit vs right implicit

Edit on GitHub

Setup

Tests

  • toString

    for (var i = 0, t = ''; i<1000; i++) {
      t = i.toString();
    }
  • String()

    for (var i = 0, t = ''; i<1000; i++) {
      t = String(i);
    }
  • left implicit

    for (var i = 0, t = ''; i<1000; i++) {
      t = ''+i;
    }
  • right implicit

    for (var i = 0, t = ''; i<1000; i++) {
      t = i+'';
    }