Javascript Map entries()

Introduction

The Javascript Map entries() method returns a new Iterator object.

The new Iterator object contains the [key, value] pairs for each element in the Map object.

It maintains the insertion order.

myMap.entries()
let myMap = new Map()
myMap.set('0', 'foo')
myMap.set(1, 'bar')
myMap.set({}, 'baz')

console.log(myMap);/*from  w  w w . j a  v a2  s.  c  o  m*/

let mapIter = myMap.entries()

console.log(mapIter.next().value)  // ["0", "foo"]
console.log(mapIter.next().value)  // [1, "bar"]
console.log(mapIter.next().value)  // [Object, "baz"]



PreviousNext

Related