728x90
문자열 메서드 : charAt() / charCodeAt()
문자열 메서드를 활용하면 원하는 문자가 포함된 문자열을 찾을 수 있습니다.
> charAt() / charCodeAt() 메서드
charAt() 위치값 이후 첫 글자를 검색하고 문자열(문자)을 반환합니다. charCodeAt() 메서드는 지정한 숫자 자리의 문자의 유니코드(숫자)를 반환합니다.
"문자열".charAt(숫자);
"문자열".charCodeAt(숫자);
"문자열".charCodeAt(숫자);
const str1 = "javascript reference";
const currentStr1 = str1.charAt(); //j
const currentStr2 = str1.charAt("0"); //j
const currentStr3 = str1.charAt("1"); //a
const currentStr4 = str1.charAt("2"); //v
const currentStr5 = str1.charCodeAt(); //106
const currentStr6 = str1.charCodeAt("0"); //106
const currentStr7 = str1.charCodeAt("1"); //97
const currentStr8 = str1.charCodeAt("2"); //118
728x90
'Javascript' 카테고리의 다른 글
GSAP 알아보기 (4) | 2022.08.29 |
---|---|
함수 유형 알아보기 (9) | 2022.08.22 |
문자열 메서드 : match() (7) | 2022.08.22 |
문자열 메서드 : search() (7) | 2022.08.22 |
문자열 메서드 : includes() (6) | 2022.08.17 |
댓글