当前位置:网站首页>set--数据解构
set--数据解构
2022-07-27 17:48:00 【小气鬼SYQ】
<script>
// 去重
var s = new Set([1, 2, 3, 3, 4, 4, 5]);
// 转数组
// console.log(Array.from(s));
// size--获取set长度
console.log(s.size);
// add--添加值,返回set本身合集
console.log(s.add(6));
// delete--删除一个值,返回布尔值
console.log(s.delete(1)); //true
console.log(s); //原数组被改变
// has--查找某个值 返回布尔值
console.log(s.has(9)); // false
// clear--清除所有成员,没有返回值,改变原数组,被清空
console.log(s.clear()); //返回undifind
console.log(s); //所有值被清空
</script>set集合也可以使用for of 遍历,以及map方法
let s = new Set(["前端", "后端", "大数据"])
console.log(s.keys()); //返回的是set集合的内容
console.log(s.values()); //返回的是set集合的内容
console.log(s.entries()); //返回的是key和values,也都是内容
// 遍历 set合集
for (var v of s.keys()) {
console.log(v);
}
for (var v of s.values()) {
console.log(v);
}
for (var v of s.entries()) {
console.log(v);
}边栏推荐
- 内置函数锁相关
- 预处理与宏定义
- Acwing 692. g bus count difference + prefix and
- js跳转页面并刷新(本页面跳转)
- [redis] redis penetration, avalanche and breakdown
- LG集团宣布将向湖北捐赠300万元现金、120万个口罩、1万套防护服
- 邬贺铨:因地制宜 数字化技术赋能“双碳”实践
- 由单片机XTALIN引脚和XTALOUT引脚导出的对晶体震荡电路的深入理解
- 10.31 extended configuration of static route
- Libpcap library and pcap_ Sendpacket interface function understanding
猜你喜欢

antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key

JS实现视频录制-以Cesium为例

电容串联与并联以及电容串联与平衡电阻

预处理与宏定义

Product Manager: check where there is an error prompt of "system exception" on the offline

Understanding of basic concepts of channel capacity and channel bandwidth

Qtexttospeech class of QT realizes voice broadcast function

Compiling ncnn with vs

'vite' is not an internal or external command, nor is it a runnable program or batch file

#yy关于鱼的英文学习
随机推荐
antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key
Introduction to reinforcement learning
Wu Hequan: digital technology empowering "double carbon" practice according to local conditions
kubectl 获取pod日志 —— 筑梦之路
技术分享 | 接口自动化测试中,如何做断言验证?
Compiling ncnn with vs
[IOT] Wei Peng: Interpretation of 6000 + words | seven necessary product management tools for product people in 2022 (version 1.0)
如何快速提升抖音小店三分钟回复率?哪些情况会影响抖音小店回复率呢?
NAT 11.16
22 year PMP test [Quanzhen agile test]
Introduction to basic cesium controls
MVCC的底层原理
2022年,软件测试还能学吗?别学了,软件测试岗位饱和了...
ViewUI 中 DatePicker 日期选择器在 IE11 浏览器中兼容解决方案
Function priority
Huawei connect conference 2022 opens Bangkok trip; Facebook pushes the video revenue sharing function, and the creator can get 20% share
内置函数锁相关
Ten year test old bird talk about mobile terminal compatibility test
Capacitance in series and in parallel and capacitance in series and balance resistance
【OpenBMC 系列】4.启动流程 使用qume模拟ast2600-evb