Set.size Property in JavaScript

HTMLJavascriptProgramming Scripts

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
raja
Published on 30-Oct-2018 06:28:59
Advertisements