JavaScript中的Set.size属性
Set对象的size属性返回数字,该数字表示当前set对象中的元素数。
语法
其语法如下
Obj.size();
示例
<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>输出结果
Size of the Set object: 4