charAt() 함수는 문자열에서 특정 인덱스에 위치하는 유니코드 단일문자를 반환한다.
사실 이 함수를 사용하지 않고 String[index]로도 사용할 수있다.
const sentence = 'The quick brown fox jumps over the lazy dog.';
const index = 4;
console.log(`The character at index ${index} is ${sentence.charAt(index)}`);
// Expected output: "The character at index 4 is q"
'javascript' 카테고리의 다른 글
Object[key] optional chaining (0) | 2024.01.03 |
---|---|
string 대문자, 소문자 체크하기 (0) | 2023.05.05 |
배열의 두 요소 순서를 변경할 때 (0) | 2023.05.05 |
Array.prototype.reduce() (0) | 2023.04.20 |
call, bind, apply의 this binding (0) | 2023.04.19 |