How to convert an array to a string in JavaScript

2 Answers

0 votes
const arr = ["javascript", "php", "c++", "python"];
 
let s = arr.toString();
 
console.log(s);
 
 
 
/*
run:
       
javascript,php,c++,python
     
*/



 

 



answered Nov 2, 2019 by avibootz
edited May 9, 2024 by avibootz
0 votes
const arr = ["javascript", "php", "c++", "python"];
 
let s = arr.join();
 
console.log(s);
 
 
 
/*
run:
       
javascript,php,c++,python
     
*/

 



answered Nov 2, 2019 by avibootz
edited May 9, 2024 by avibootz

Related questions

2 answers 107 views
1 answer 146 views
1 answer 216 views
1 answer 144 views
1 answer 128 views
1 answer 92 views
...