这个函数返回一个iterator包含 Map 中每个元素的键值对。
用法
entries() 的语法如下所示
map_name.entries()
示例
<script>
let andy = {ename:"Andrel"},
varun = {ename:"Varun"},
prijin = {ename:"Prijin"}
let empJobs = new Map([
[andy,'Software Architect'],
[varun,'Developer']]
);
for(let row of empJobs.entries()){
console.log("key is ",row[0])
console.log("value is ",row[1])
}
</script>
上面代码的输出如下图所示
key is {ename:"Andrel"} value is Software Architect key is {ename:"Varun"} value is Developer
相关用法
注:本文由纯净天空筛选整理自 ES6 - Map Method entries()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。