JavaScript中的Map.entries()函数
entries()Map对象的功能返回相应Map对象的迭代器,使用该迭代器可以检索映射的键值对。
语法
其语法如下
mapVar.entries()
示例
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var mapVar = new Map();
mapVar.set('1', 'Java');
mapVar.set('2', 'JavaFX');
mapVar.set('3', 'HBase');
mapVar.set('4', 'Neo4j');
var it = mapVar.entries();
for(i=0; i<mapVar.size; i++) {
document.write(it.next().value);
document.write(" <p> ");
}
</script>
</body>
</html>输出结果
1,Java 2,JavaFX 3,HBase 4,Neo4j
示例
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var mapVar = new Map();
mapVar.set('1', 'Raju');
mapVar.set('2', 'Ram');
mapVar.set('3', 'Rahim');
mapVar.set('4', 'Robert');
var it = mapVar.entries();
document.write(it.next().value);
document.write("<br>");
document.write(it.next().value);
</script>
</body>
</html>输出结果
1,Raju 2,Ram
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短