Languages
[Edit]
EN

JavaScript - print Set items

3 points
Created by:
ArcadeParade
276

In this article, we would like to show you how to print Set items in JavaScript.

Quick solution:

// ONLINE-RUNNER:browser;

const mySet = new Set();

mySet.add('1');
mySet.add('2');
mySet.add('3');

console.log(...mySet);

 

Practical example

In this example, we use spread operator (...) wrapped with square brackets to print set items in the console.

Runnable example

// ONLINE-RUNNER:browser;

const mySet = new Set();

mySet.add('1');
mySet.add('2');
mySet.add('3');

console.log(...mySet);

See also

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join