JavaScript – Get Length/Size of a Set
To get length or size of a Set in JavaScript, access size property of this Set. size is a read only property of Set object and returns an integer value representing the number of elements in this Set.
Syntax
The syntax to access size property on the Set set1
is
set1.size;
ADVERTISEMENT
Examples
In the following example, we take a Set with two elements and find the size of this Set programmatically using size property.
index.html
The size of an empty Set is zero.
index.html
Conclusion
In this JavaScript Tutorial, we learned how to get the size of a Set in JavaScript using size property, with examples.