Is there any difference in time complexity between [1,2,3].toString() and [1,2,3].join() . As I understand time complexity of join function is O(n) . What is the time complexity of .toString() method ?
Is there any difference in time complexity between [1,2,3].toString() and [1,2,3].join() . As I understand time complexity of join function is O(n) . What is the time complexity of .toString() method ?
Both have the same time complexity. Array.prototype.toString calls Array.prototype.join without argument. ',' is the default separator.
toString() has the same time complexity of join(), the difference is that with join() is possible to choose the separator.
array.join([separator]);