1['tom', 'dick', 'harry'].join(', ').replace(/, ([^,]*)$/, ' and $1')
2> "tom, dick and harry"
1const arr = [1, 2, 'a', '1a'];
2const str = arr.toString();
3console.log(str); //> "1,2,a,1a"
1var cars = ["Volvo", "BMW", "Audi", "Chevrolet"];
2console.log(cars.toString());
3//Output: Volvo,BMW,Audi,Chevrolet
1// If you want to split on a specific character in a string:
2const stringToSplit = '01-02-2020';
3console.log(stringToSplit.split('-'));
4// ["01", "02", "2020"]
5
6// If you want to split every character:
7const stringToSplit = '01-02-2020';
8console.log(Array.from(stringToSplit));
9// ["0", "1", "-", "0", "2", "-", "2", "0", "2", "0"]