How to Get the "length" of 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();


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

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.