Create a Comma Separated List from an Array in JavaScript Last Updated : 28 Jun, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Creating a comma-separated list from an array is a common task in JavaScript, especially when formatting data for display, creating CSV strings, or sending readable outputs to users or servers. Over 75% of JavaScript applications use some form of array-to-string conversion for logging, UI rendering, or data transmission. JavaScript provides simple and best methods like .join() to seamlessly transform arrays into well-formatted, comma-separated strings.Here are the different methods to create a comma-separated list from an Array1. Array join() methodThe Array join() method joins the elements of the array to form a string and returns the new string. The elements of the array will be separated by a specified separator. index.js let a = ["GFG1", "GFG2", "GFG3"]; function fun() { console.log("Comma Separates List: " + a.join(", ")); } fun(); OutputoutputCode OverviewThe code defines an array containing three elements: "GFG1", "GFG2", and "GFG3".The function uses a.join(", ") to create a comma-separated list of the array elements and log it to the console.2. Array toString() methodArray toString() method converts an array into a String and returns the new string. It returns a string that represents the values of the array, separated by a comma. index.js let a = ["GFG1", "GFG2", "GFG3"]; function fun() { console.log("Comma Separated List: " + a.toString()); } fun(); OutputoutputCode OverviewThe code defines an array with elements "GFG1", "GFG2", and "GFG3".The function uses the toString() method to convert the array into a string, with the elements separated by commas by default.3. Using Array literalsArray literals is the list of expressions containing array elements separated with commas enclosed with square brackets. index.js let a = ["GFG1", "GFG2", "GFG3"]; function fun() { console.log("Comma Separated List: " + a); } fun(); OutputoutputCode OverviewThe code defines an array with elements "GFG1", "GFG2", and "GFG3" using an array literal.The function directly logs the array arr to the console. When an array is logged as a string, JavaScript automatically converts it to a comma-separated list.4. Using Lodash _.join() methodLodash _.join() method return the list of given array with "," separation. index.js // Requiring the lodash library let _ = require("lodash"); let a = [1, 2, 3, 4, 5, 6]; let newA = _.join(a); console.log("After Join: " + newA); OutputoutputCode OverviewThe code imports the lodash library using require("lodash"), enabling access to its utility functions.The _.join(array) function from Lodash is used to join the elements of the array into a string, with the default separator being a comma.5. Using map() and join()To create a comma-separated list from an array using map() and join(), first convert each array element to a string using map(String), then join these strings into a single string separated by commas using join(','). index.js const a = [1, 2, 3, 4, 5]; const comma = a.map(String).join(','); console.log(comma); OutputoutputCode OverviewThe code uses map(String) to convert each element of the array arr into a string, and then join(',') joins these string elements with commas.The result is a comma-separated string "1,2,3,4,5", which is logged to the console. Comment More infoAdvertise with us Next Article Create a Comma Separated List from an Array in JavaScript P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies javascript-array JavaScript-DSA JavaScript-Questions +1 More Similar Reads JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Introduction to Tree Data Structure Tree data structure is a hierarchical structure that is used to represent and organize data in the form of parent child relationship. The following are some real world situations which are naturally a tree.Folder structure in an operating system.Tag structure in an HTML (root tag the as html tag) or 15+ min read Domain Name System (DNS) DNS is a hierarchical and distributed naming system that translates domain names into IP addresses. When you type a domain name like www.geeksforgeeks.org into your browser, DNS ensures that the request reaches the correct server by resolving the domain to its corresponding IP address.Without DNS, w 8 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net 15+ min read Web Development Technologies Web development refers to building, creating, and maintaining websites. It includes aspects such as web design, web publishing, web programming, and database management. It is the creation of an application that works over the internet, i.e., websites.To better understand the foundation of web devel 7 min read Like