JavaScript(JS) array method - tostring

The toString() method in JavaScript is used to convert an array to a string. This method returns a string representing the elements of the array, separated by commas.

Here is an example of using the toString() method:

refer ‮ot‬:theitroad.com
const fruits = ['apple', 'banana', 'cherry'];
const string = fruits.toString();
console.log(string); // "apple,banana,cherry"

In the example above, the toString() method is used to convert the fruits array to a string. The resulting string is "apple,banana,cherry".

Note that the toString() method does not modify the original array. Instead, it returns a new string that represents the array elements.