Kimyeongkyung
지정 접미사로 끝나는지 판단하는 메서드 endsWith() 본문
endsWith() 생소한 메서드여서 공부해보기로 했다.
프로그래머스 코딩테스트 연습하다가 알게 된 메서드인데, 어떤 문자열이 지정 문자열로 끝나는지 판단하는 메서드라고 한다.
string.endsWith( searchString, length )
예를 들어보자면,
const text = "abcde";
// text에 "e"가 포함되는지
text.endsWith( 'e' )
// true
// "abc"에 "e"가 포함되는지
text.endsWith( 'e', 3 )
// false
endsWith()는 대소문자를 구분한다.
const text2 = "abcdE";
// text에 "de"가 포함되는지
text.endsWith( 'de' )
// false
참고자료
'important' 카테고리의 다른 글
Heroku(헤로쿠) 보안코드 인증 실패 문제 해결(feat. Salesforce Authenticator App) (1) | 2024.01.23 |
---|---|
replace() vs replaceAll() (0) | 2023.08.23 |
Axios interceptors (0) | 2023.04.12 |
단언 연산자 (!.) (0) | 2023.04.10 |
fatal: too many arguments for a rename operation 에러 (0) | 2023.04.05 |