当前位置:网站首页>[map set]
[map set]
2022-07-27 20:16:00 【Cheapskate syq】
new An instance Map aggregate :
let m = new Map();1、map Properties of :size
return map Number of elements of
2、map Methods :
<script>
// new An instance Map aggregate
let m = new Map();
// set- Set key sum value , Returns the added map( Assigning a value to an existing key will overwrite the previous value
m.set("name", " Zhang San ");
m.set(5, " bachelor ")
m.set("5", " golden bachelor ")
m.set("", "111")
console.log(m);
// get- Get a key Value , return key Corresponding value , No return undefined
console.log(m.get(5));
// has- Detect if there is a key, Returns a Boolean value
console.log(m.has(6));
// delete- Delete some key And the corresponding value, Returns a Boolean value , If it is successfully deleted, it will be true
console.log(m.delete(5));
console.log(m);
// clear return undefind, The original array is emptied
console.log(m.clear());
</script>3、 Traverse the way :
for of Only arrays can be traversed , Traversal is map The iterator ;for in Only objects can be traversed ;
// Use for of Can be used to cycle map iterator
for (var key of m.keys()) {
console.log(key); // Return key
}
for (var v of m.values()) {
console.log(v); // Return value
}
for (var e of m.entries()) {
console.log(e); // Returns an array of , The first item of the array is the key , The second item is the value
}
// for of You can only traverse arrays , And traverse all elements , for in You can only traverse objects
var arr = [{ name: " Zhang San ", age: 30 }, { name: " Zhang San ", age: 30 }]
for (var item of arr) {
console.log(item);
}边栏推荐
- Use cpolar to build a business website (5)
- What does bus mean
- Huawei's mobile phone shipments exceed Apple's, ranking second in the world, but it faces a large amount of inventory that needs to be cleaned up
- ViewUI 中 DatePicker 日期选择器在 IE11 浏览器中兼容解决方案
- Online judge output overrun
- Clickhouse 实现 MaterializedPostgreSQL
- shell
- C语言--数组
- How to run kevinchappell / FormBuilder
- Zepto入门详解
猜你喜欢

TS2532: Object is possibly ‘undefined‘

UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xff in position 0: invalid start byte

What does bus mean

C语言--数组

图解LeetCode——592. 分数加减运算(难度:中等)

codeforces每日5题(均1500)-第二十四天

MVCC的底层原理
![22 year PMP test [Quanzhen agile test]](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
22 year PMP test [Quanzhen agile test]

Codeworks 5 questions per day (average 1500) - day 24

邬贺铨:因地制宜 数字化技术赋能“双碳”实践
随机推荐
继华为、联发科之后,这家手机芯片厂商宣布向武汉捐款700万
华为全联接大会2022开启曼谷之旅;Facebook推视频收入分成功能,创作者可获20%分成…
An in-depth understanding of crystal oscillation circuit derived from xtalin pin and xtalout pin of single chip microcomputer
[redis] several deployment methods of redis
Huawei connect conference 2022 opens Bangkok trip; Facebook pushes the video revenue sharing function, and the creator can get 20% share
速卖通:按关键字搜索商品 API
Connection pool - return connection details (Part 1)
C171: attendance system
Use cpolar to build a business website (5)
Ten year test old bird talk about mobile terminal compatibility test
SQLite SQL writing method of creating table joint primary key
Redis-基本了解,五大基本数据类型
YY English learning about fish
es6删除对象的属性_ES6删除对象中的某个元素「建议收藏」
Capacitance in series and in parallel and capacitance in series and balance resistance
Codeforces Round #810 (Div. 2)B.party(思维题)超详细题解
js跳转页面并刷新(本页面跳转)
使用cpolar建立一个商业网站(5)
Why do we need third-party payment?
New library online | cnopendata detailed address data of all patents in China