keys()
메서드는 배열의 각 인덱스를 키 값으로 가지는 새로운 Array Iterator
객체를 반환합니다.
구문
arr.keys()
반환 값
새로운 Array
반복기 객체.
예제
키 반복기는 빈 인덱스를 무시하지 않음
var arr = ['a', , 'c'];
var sparseKeys = Object.keys(arr);
var denseKeys = [...arr.keys()];
console.log(sparseKeys); // ['0', '2']
console.log(denseKeys); // [0, 1, 2]
명세
Specification | Status | Comment |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Array.prototype.keys' in that specification. |
Standard | Initial definition. |
ECMAScript (ECMA-262) The definition of 'Array.prototype.keys' in that specification. |
Living Standard |
브라우저 호환성
BCD tables only load in the browser