toString() vs join() (v12)

Revision 12 of this benchmark created by Sriram Krishnan on


Preparation HTML

<script>
  var array = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten'];
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
toString()
var string = "value:" + array.toString();
ready
join()
var string = "value:" + array.join();
ready
join(",")
var string = "value:" + array.join(",");
ready
none
var string = "value:" + array;
ready
toString() and replace
var string = "value:" + array.toString().replace(/,/g, '","');
ready
array and replace
var string = "value:" + ((array + "").replace(/,/g, '","'));
ready

Revisions

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