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: 25-Jun-2020

288 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements