| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Array/keys | [Back] [Original] |
Get to know MDN better
const array = ["a", "b", "c"];
const iterator = array.keys();
for (const key of iterator) {
console.log(key);
}
// : 0
// : 1
// : 2
keys()
Object.keys() keys()
const arr = ["a", , "c"];
const sparseKeys = Object.keys(arr);
const denseKeys = [...arr.keys()];
console.log(sparseKeys); // ['0', '2']
console.log(denseKeys); // [0, 1, 2]
keys() this length 0 length - 1
const arrayLike = {
length: 3,
};
for (const entry of Array.prototype.keys.call(arrayLike)) {
console.log(entry);
}
// 0
// 1
// 2
| ECMAScript 2027 LanguageSpecification # sec-array.prototype.keys |
Arrayat()concat()copyWithin()entries()every()fill()filter()find()findIndex()findLast()findLastIndex()flat()flatMap()forEach()includes()indexOf()join()keys()lastIndexOf()map()pop()push()reduce()reduceRight()reverse()shift()slice()some()sort()splice()toLocaleString()toReversed()toSorted()toSpliced()toString()unshift()values()with()[Symbol.iterator]()Object/Function| Web Proxy Viewer | New URL | Original Page |