当前位置:网站首页>Set set
Set set
2022-07-27 08:18:00 【huijie_ 0716】
One 、 Statement set aggregate
var x = new Set();
var y = new Set(['qiku', 123, 123, true]);
Two 、 Add data
x.add('qiku');
x.add(1);
x.add(15);
3、 ... and 、 Delete data
var w = x.delete(77); Delete a data
x.clear(); Empty data
Four 、 lookup
console.log(y.has('qiku')); //true return true or false
5、 ... and 、 modify ( Replace )
if (y.delete(123)) {
y.add(88);
}
6、 ... and 、 Traverse
var s = y.forEach(function(value) {
console.log(value);
})console.log(y.size); The length of the array
7、 ... and 、keys /values /entries
console.log(y.keys())
for (let i of y.keys()) {
console.log(i)
}
console.log(y.values())
for (let i of y.values()) {
console.log(i)
}
console.log(y.entries())
for (let [i, j] of y.entries()) {
console.log(i, j)
}8、 ... and 、 Whether it is equal or not
function Person(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
var z = new Person(' Zhang San ', 18, ' male ');
var a = new Person(' Zhang San ', 18, ' male ');
console.log(a == z);Not equal
Nine 、 Additive data
var b = new Set(['qiku', 123, 123, true]);
var c = new Set([1, 2, 'qiku', 123, 123, true]);
var arr1 = Array.from(b);
var arr2 = Array.from(c);
console.log(new Set(arr1.concat(arr2)));
边栏推荐
- 好吃难吃饱七分为宜;好喝难喝醉三分为佳
- docker 安装mysql后进入容器内部发现登录不了mysql
- [geek challenge 2019] finalsql 1
- Containerd failed to pull private database image (kubelet)
- Demo:st05 find text ID information
- [ciscn2019 southeast China division]web11 1
- Use of NPM
- XxE & XML vulnerability
- QT creator code style plug-in beautifier
- [NPUCTF2020]ReadlezPHP 1
猜你喜欢

面试官:什么是脚手架?为什么需要脚手架?常用的脚手架有哪些?

An ordinary autumn recruitment experience

regular expression

Qt Creator代码风格插件Beautifier

QT creator code style plug-in beautifier

【目标检测】YOLOv6理论解读+实践测试VisDrone数据集

The seta 2020 international academic conference will be held soon. Welcome to attend!

File name wildcard rules for kettle

Digital transformation driven by enterprise architecture!

Graph node deployment and testing
随机推荐
The seta 2020 international academic conference will be held soon. Welcome to attend!
Teach you to build a nail warning robot hand in hand
idea远程调试
Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market
SETTA 2020 国际学术会议即将召开,欢迎大家参加!
代码接口自动化的有点
Modification case of Ruixin micro rk3399-i2c4 mounting EEPROM
IBM3650M4实体机安装VCenter7.0
Introduction, installation and use of netdata performance monitoring tool
The response of the database interface is very slow
2022/7/26 exam summary
STM32小bug汇总
[target detection] yolov6 theoretical interpretation + practical test visdrone data set
"PHP Basics" tags in PHP
Attack and defense World Lottery
mqtt指令收发请求订阅
Eval and assert execute one sentence Trojan horse
Ubuntu: install PostgreSQL
虚拟机克隆
STM32 small bug summary