Set Size Property in JavaScript



The size property of the Set object returns number representing the number of elements in the current set object.

Syntax

Its Syntax is as follows

Obj.size();

Example

 Live Demo

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      const setObj = new Set();
      setObj.add('Java');
      setObj.add('JavaFX');
      setObj.add('JavaScript');
      setObj.add('HBase');
      document.write("Size of the Set object: "+setObj.size);
   </script>
</body>
</html>

Output

Size of the Set object: 4
Updated on: 2020-06-25T12:54:46+05:30

360 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements