Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
Array 인스턴스의 length 데이터 속성은 해당 배열의 요소 수를 나타냅니다. 해당 값은 부호 없는 32비트 정수이며 배열의 최대 인덱스 보다 항상 큽니다.
232보다 작은 음수가 아닌 정수.
| 쓰기 가능 | 가능 |
| 열거 가능 | 불가능 |
| 설정 가능 | 불가능 |
length 속성의 값은 양의 정수이며 232 미만의 값을 가집니다.
배열 객체는 length 속성을 주시하여, length 값을 배열의 내용과 자동으로 동기화합니다. 이것은 다음을 의미합니다.
length가 현재 길이보다 큰 값으로 설정되면 실제 undefined 값이 아닌 빈 슬롯을 추가하여 배열을 확장합니다. 빈 슬롯은 배열 방법과 몇 가지 특별한 상호 작용을 합니다. 배열 방법과 빈 슬롯을 참조하십시오.
length와 숫자 속성의 관계를 참고하시기 바랍니다.
다음 예제는 numbers 배열을 length 속성의 크기만큼 순회합니다. 각 원소의 값은 두 배가 됩니다.
다음 예제는 numbers 배열의 현재 길이가 3보다 클 경우 3으로 줄입니다.
length를 현재 크기보다 더 크게 설정하면 희소 배열을 생성합니다.
length 속성은 현재 길이를 넘어 요소가 추가되면 Array에 의해 자동으로 업데이트됩니다. length 속성이 쓰기 불가능한 경우 Array는 이를 업데이트할 수 없습니다. 이로 인해 엄격 모드에서 오류가 발생합니다.
| ECMAScript® 2027 Language Specification # sec-properties-of-array-instances-length |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 10월 10일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.