Node.js - Convert list to string

by
Jeremy Canfield |
Updated: November 19 2024
| Node.js articles
This is a list that contains values. You can print the list.
const fruits = ["Apple", "Orange", "Banana", "Pineapple"];
console.log(fruits);
Which should return the following.
~]$ node app.js
[ 'Banana', 'Orange', 'Apple', 'Mango' ]
toString can be used to convert the list into a string.
const fruits = ["Apple", "Orange", "Banana", "Pineapple"];
console.log(fruits);
console.log(fruits.toString());
Which should return the following.
[ 'Apple', 'Orange', 'Banana', 'Pineapple' ]
Apple,Orange,Banana,Pineapple
Did you find this article helpful?
If so, consider buying me a coffee over at