Bootstrap FreeKB - Node.js - Convert list to string
Node.js - Convert list to string

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter e94324 in the box below so that we can be sure you are a human.