A-C > Array.length |
Array.length
지원 버전
Flash Player 5
구문
myArray.length
설명
속성; 배열의 길이를 저장합니다. 이 속성은 새 요소가 배열에 추가될 때 자동으로 업데이트됩니다. 배열 요소에 특정 값을 지정하는 경우(예: myArray[index] = value), index가 숫자이고 index+1이 length 속성보다 크다면 length 속성은 index + 1로 업데이트됩니다.
예제
다음 코드에서는 length 속성 업데이트 방법에 대해 설명합니다.
// initial length is 0 myArray = new Array(); myArray[0] = 'a'; // myArray.length is updated to 1 myArray[1] = 'b'; // myArray.length is updated to 2 myArray[9] = 'c'; // myArray.length is updated to 10