Integer to string

Benchmark created by Martijn on


Preparation HTML

<script>
  var dest, source = 42,
      anything = /(.|\n|\r)*/;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
String function
dest = String(source);
ready
Empty string type coercion
dest = "" + source;
ready
toString function
dest = source.toString();
ready
Hefty regex
dest = /(.|\n|\r)*/.exec(source)[0];
ready
Hefty regex, cached
dest = anything.exec(source)[0];
ready
Array join
dest = [source].join("");
ready
Number prototype toString
dest = Number.prototype.toString.call(source);
ready

Revisions

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