This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Set.prototype.keys()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015년 7월⁩.

Set 인스턴스의 keys() 메서드는 values() 메서드의 별칭입니다.

구문

js
keys()

매개변수

없음.

반환 값

새로운 순회 가능한 반복자 객체.

예제

keys() 사용하기

keys() 메서드는 values()와 완벽하게 동일합니다.

js
const mySet = new Set();
mySet.add("foo");
mySet.add("bar");
mySet.add("baz");

const setIter = mySet.keys();

console.log(setIter.next().value); // "foo"
console.log(setIter.next().value); // "bar"
console.log(setIter.next().value); // "baz"

명세서

Specification
ECMAScript® 2026 Language Specification
# sec-set.prototype.keys

브라우저 호환성

같이 보기