JavaScript 中的 Set.size 属性
htmljavascriptprogramming scripts更新于 2024/10/14 0:12:17
Set 对象的 size 属性返回表示当前 set 对象中元素数量的数字。
语法
其语法如下
Obj.size();
示例
<html>
<head>
<title>JavaScript 示例</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
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

