- Using join() method
- Using toString() method
- Using an empty string
Check out all JavaScript examples at https://www.javaguides.net/p/javascript-tutorial-with-examples.html
1. Using join() method
const strArry = ['r','a','m', 'e', 's', 'h'];
console.log(strArry.join());
r,a,m,e,s,h
const arr = ['r','a','m', 'e', 's', 'h', 1,2,3];
console.log(arr.join());
r,a,m,e,s,h,1,2,3
const arr = ['r','a','m', 'e', 's', 'h', 1,2,3];
console.log(arr.join('-'));
r-a-m-e-s-h-1-2-3
2. Using toString() method
const strArry = ['r','a','m', 'e', 's', 'h'];
console.log(strArry.toString());
r,a,m,e,s,h
3. Using an empty string
const strArry = ['r','a','m', 'e', 's', 'h'];
console.log(strArry + '');
r,a,m,e,s,h
Continue Learning with Java Guides
Want to take your programming skills to the next level? Explore my practical Udemy courses on Java, Spring Boot, Microservices, Full-Stack Development, Docker, and Generative AI. You can also follow my structured learning roadmaps to become a professional developer.
By Ramesh Fadatare - Udemy Instructor Partner
Comments
Post a Comment
Leave Comment