Number to String

JavaScript performance comparison

Test case created by scunliffe

Info

Comparing speeds of various methods to convert a number to a string.

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Concat with an empty string
var foo = 45;
var bar = '' + foo;
pending…
Calling .toString
var foo = 45;
var bar = foo.toString();
pending…
New String Object
var foo = 45;
var bar = new String(foo);
pending…
Concat empty string as suffix
var foo = 45;
var bar = foo + '';
pending…
PlusEquals concatination
var foo = 45;
var bar = '';
bar += foo;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment