VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-set-size-property/

⇱ JavaScript Set size Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Set size Property

Last Updated : 23 Jul, 2025

The Set.size property in JavaScript returns the number of elements in a Set. In other words, we can say that this property is used to get the current size of the set. If the Set is empty the size of the set will be returned as 0.

Syntax:

mySet.size

Return Type:

  • Number of elements in the set

Example 1: In this example, we will see the use of the Javascript Set.size property.

Output:

Set(2) { 23, 12 }
2

Example 2: In this example, we will see the use of the Javascript Set.size property.

Output:

3

Supported Browsers:

  • Google Chrome
  • Firefox
  • Opera
  • Edge
  • Safari
Comment