

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to turn JavaScript array into the comma-separated list?
To turn JavaScript array into a comma-separated list, use the Array.join() method. JavaScript array join() method joins all the elements of an array into a string. The following is the syntax −
Syntax
array.join(separator);
The following is the parameter −
- separator − Specifies a string to separate each element of the array. If omitted, the array elements are separated by a comma.
Example
You can try to run the following code to turn JavaScript array into a comma-separated list −
<html> <head> <title>JavaScript Array join Method</title> </head> <body> <script> var arr = new Array("Java","PHP","Ruby"); var str = arr.join(); document.write("str : " + str ); var str = arr.join(", "); document.write("<br />str : " + str ); </script> </body> </html>
- Related Questions & Answers
- Convert String into comma separated List in Java
- How to create comma separated list from an array in PHP?
- How to split comma and semicolon separated string into a two-dimensional array in JavaScript ?
- How to convert comma separated text in div into separate lines with JavaScript?
- Display MySQL Results as comma separated list?
- How to turn a JSON object into a JavaScript array in JavaScript ?
- How do I turn a list into an array in Java?
- How to convert array of comma separated strings to array of objects?
- How to convert a comma separated String into an ArrayList in Java?
- How to turn words into whole numbers JavaScript?
- How to set a comma separated list as a table in MySQL?
- MySQL query to retrieve records from the part of a comma-separated list?
- Java Program to Convert a List of String to Comma Separated String
- How to turn a String into a JavaScript function call?
- Convert a List of String to a comma separated String in Java
Advertisements