Computer >> Computer tutorials >  >> Programming >> Javascript

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

<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