
es6语法中如何运用Set,下面web建站小编给大家详细介绍一下代码的运用!
添加数据
let set = new Set([1, 2, 2, 4, 4]); let addSet = set.add(5); console.log(addSet); //Set(4) {1, 2, 4, 5}
删除数据
let set = new Set([1, 2, 2, 4, 4]); let delSet = set.delete(4); console.log(delSet); //true
查看是否存在数据
let set = new Set([1, 2, 2, 4, 4]); let hasSet = set.has(4); console.log(hasSet); //true
清除所有数据
let set = new Set([1, 2, 2, 4, 4]);
set.clear();
console.log(set); //Set(0) {size: 0}
上面是“es6语法中关于Set的运用方法”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3155.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

GPT-5.3 Codex:融合编程能力与专业推理知识OpenAI智能编码模型
mysql索引失效一般是有哪些原因造成的
In3D:一个能快速生成你的虚拟形象的AI工具
如何添加导入链接进行网站优化?
苏珊米勒(Susan Miller)占星家中文网网页版官方入口
基于Vue3/Vite/TS免费开源中后台前端框架——Naive Ui Admin