Skip to content

How to convert JavaScript Array to comma separated string?

In this small post, let’s take a look at how to convert an array of elements to a CSV string in JavaScript.

You can use Array.prototype.join() method to join the array elements with a special character and convert it to CSV.

var cities = ["New York", "Manchester", "Sydney"];
let csv = cities.join(",");
//New York,Manchester,Sydney
See also  Timing events in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.