JavaScript 中的 Map.size 属性

javascripthtmlweb developmentfront end technology

Map 对象的 size 属性接受 JSON 字符串,并根据给定的文本构造一个对象并返回它。

语法

其语法如下

mapVar.size

示例

<html>
<head>
   <title>JavaScript 示例</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>

输出

Size of the map object: 4

相关文章