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 送给学长毕业祝福语简短