Favorites

JavaScript Set.prototype.size Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Set.prototype.size
JavaScript Set Instance propertyThis property is supported by all modern browsers.
Updated 28th November 2026

The size property gives the number of values in a Set.

Description

The size property returns the number of unique values in the set. Comparing it with an array's length is a quick duplicate check.

It's read-only: to remove values, use delete() or clear(). Checking set.size === 0 tells you whether a set is empty.

A WeakSet has no size, because its members can be garbage-collected at any time, so its contents can't be counted reliably.

Syntax

set.size

Value

The number of values in the Set.

Example

const list = ['a', 'b', 'a'];
console.log(new Set(list).size !== list.length ? 'has duplicates' : 'unique');

Browser Support

The following information will show you the current browser support for the Set.prototype.size property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee