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 July 2015.
Phương thức keys() của các instance Set là bí danh cho phương thức values().
Cú pháp
js
keys()
Tham số
Không có.
Giá trị trả về
Một đối tượng iterator có thể lặp mới.
Ví dụ
>Sử dụng keys()
Phương thức keys() hoàn toàn tương đương với phương thức 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"
Đặc tả kỹ thuật
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-set.prototype.keys> |