To convert a Set to String in JavaScript, “convert a Set to an array and then call the join() method on that array.”
Here’s a step-by-step breakdown of how to convert a set to a string:
- Convert the Set to an array using Array.from() method.
- Use the Array.join() method on the resulting array to concatenate its elements into a string.
const main_set = new Set(['a', 'b', 'c']);
// Convert the Set to an array and
// Then join its elements into a string
const str = Array.from(main_set).join(', ');
console.log(str);
Output
a, b, c
Use the spread operator (…).
const main_set = new Set(['a', 'b', 'c']);
// Convert the Set to an array and
// Then join its elements into a string
const str = [...main_set].join(' ');
console.log(str);
Output
a b c
You can change the delimiter inside join() to any other string if you want a different separator between elements.
Related posts
Object to String in JavaScript

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.