Javascript
자바스크립트 length 문자열/숫자열 길이구하기
babydeveloper
2022. 4. 14. 17:51
문자열 속성 : length : 문자열 길이 구하기 : 반환(숫자)
.length는 문자열이나 숫자열 길이를 반환하는 속성입니다.
{
const str1 = "자바스크립트";
const currentStr1 = str1.length;
const str2 = "javascript";
const currentStr2 = str2.length;
}
| 번호 | 기본값 | 메서드 | 결괏값 |
| 1 | 자바스크립트 | length | 6 |
| 2 | javascript | length | 10 |
{
const arrNum = [100, 200, 300, 400, 500];
const arrNumLength = arrNum.length;
const arrText = ['a', 'b', 'c', 'd', 'e'];
const arrTextLength = arrText.length;
const arr = [1, 2, ['a', 'b']];
const arrLength = arr.length;
}
| 번호 | 기본값 | 메서드 | 결괏값 |
| 1 | [100, 200, 300, 400, 500] | .length | 5 |
| 2 | ['a', 'b', 'c', 'd', 'e'] | .length | 5 |
| 3 | [1, 2, ['a', 'b']]; | .length | 3 |
반응형