What is Array.join() ?
By default, it adds a comma to resulting values, though you can also specify that it adds nothing or some other separator value.
Syntax of Array.join() Method.
Here, Array refers to an array that you want to join and the separator is an optional value that can either be used as a parameter or not. Its default value is comma(, ).
const alphabets = ['a', 'b', 'c'] const joinedString = alphabets.join('') console.log(joinedString) // Output 'a,b,c'
['a', 'b', 'c'].toString(); // 'a,b,c'
However, this method is not the correct way of doing things but it works though. Here is an example of the same.
['a', 'b', 'c'] + ; // 'a,b,c' ['a', 'b', 'c'] + ''; // 'a,b,c'
JSON.stringify(['a', , 'b', 'c']); // '['a', , 'b','c']'