Map.prototype.entries()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

entries() 메서드는 새 반복자 객체를 반환합니다. 이 객체에는 Map 객체의 각 요소에 대한 [key, value] 쌍이 삽입 순서대로 포함됩니다. 이 특별한 경우, 이 반복자 객체도 반복이 가능하므로 for-of 루프를 사용할 수 있습니다. [Symbol.iterator] 프로토콜이 사용될 경우, 호출될 때 반복자 자체를 반환하는 함수를 반환합니다.

시도해보기

구문

js
entries()

반환 값

예제

entries() 사용하기

js
const myMap = new Map();
myMap.set("0", "foo");
myMap.set(1, "bar");
myMap.set({}, "baz");

const mapIter = myMap.entries();

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

명세서

Specification
ECMAScript Language Specification
# sec-map.prototype.entries

브라우저 호환성

BCD tables only load in the browser

같이 보기