How to Get the "length" of JavaScript Set Object?

Find out how to get the size of a JavaScript Set object

Unlike JavaScript arrays, the Set object does not have a length property. It does, however, have a size accessor property, which gives you number of elements in a Set object.

For Example:

const set = new Set();

set.add(1);
set.add(2);
set.add(3);

console.log(set.size); // 3

Hope you found this post useful. It was published . Please show your love and support by sharing this post.