Cast To String (v4)

Revision 4 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
String Function
var myVar = 87,
    newString;
newString = String(myVar);
ready
String Constructor
var myVar = 87,
    newString;
newString = new String(myVar);
ready
Concatenate Empty String
var myVar = 87,
    newString;
newString = myVar + "";
ready
toString Method
var myVar = 87,
    newString;
newString = myVar.toString();
ready
""
var myVar = 87,
    newString;
newString = "" + myVar;
ready
null
var myVar = null,
    newString;
newString = String(myVar);
ready
"" + null
var myVar = null,
    newString;
newString = "" + myVar;
ready
null + ""
var myVar = null,
    newString;
newString = myVar + "";
ready
undefined
var myVar, newString;
newString = String(myVar);
ready
"" undefined
var myVar, newString;
newString = "" + myVar;
ready
undefined ""
var myVar, newString;
newString = myVar + "";
ready

Revisions

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