toString() vs join() (v10)

Revision 10 of this benchmark created by Joe H on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
  var array = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','one', 'two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','two', 'three', 'four', 'five', 'six', 'seven', 'height', 'nine', 'ten','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
Implicit toString()
var string = "value:" + array;
ready
$.trim()
var string = "value:" + $.trim(array);
ready
Map Concat
var string = "value:"
 
array.map(function(item){ 
  string += item + "," 
})

string = string.slice(0,-1)
ready
Conditional Map Concat
var string = "value:"
    stopIndex = array.length - 1
 
array.map(function(item){ 
  string += item
  if(i != stopIndex) string += "," 
})
ready

Revisions

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