Map对象的size属性接受一个JSON字符串,并根据给定的文本构造一个对象,然后将其返回。
其语法如下
mapVar.size
<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>输出结果
Size of the map object: 4