concat vs op vs toString Method vs String Function

Edit on GitHub

cast to string

Setup

Tests

  • concat

    var myVar = 87,
        newString;
    newString = "".concat(myVar);
  • op

    var myVar = 87,
        newString;
    newString = "" + myVar;
  • toString Method

    var myVar = 87,
        newString;
    newString = myVar.toString();
  • String Function

    var myVar = 87,
        newString;
    newString = String(myVar);