Map.size property in JavaScript


The size property of Map object accepts a JSON string, and constructs an object based on the given text and, returns it.

Syntax

Its Syntax is as follows

mapVar.size

Example

 Live Demo

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var mapVar = new Map();
      mapVar.set('1', 'Java');
      mapVar.set('2', 'JavaFX');
      mapVar.set('3', 'HBase');
      mapVar.set('4', 'Neo4j');
      document.write("Size of the map object: "+mapVar.size);
   </script>
</body>
</html>

Output

Size of the map object: 4

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 25-Jun-2020

469 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements