Cast To String (v21)

Revision 21 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Conditional Concatenate Empty String
var myVar = "87",
    newString;
newString = typeof myVar === "string" ? myVar : myVar + "";
ready
toString Method
var myVar = 87,
    newString;
newString = myVar.toString();
ready
Conditional Concatenate Empty String
var myVar = 87,
    newString;
newString = typeof myVar === "string" ? myVar : myVar + "";
ready
String Constructor
var myVar = 87,
    newString;
newString = new String(myVar);
ready
Concatenate Empty String
var myVar = 87,
    newString;
newString = myVar + "";
ready
String Function
var myVar = 87,
    newString;
newString = String(myVar);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.