통합 검색
통합 검색
문자열 메서드 :
includes()
: 이 메서드는 문자열이 특정 부분 문자열을 포함하고 있는지 여부를 확인합니다. 포함하고 있으면 true
를 반환하고, 그렇지 않으면 false
를 반환합니다.
javascriptconst str = 'Hello, World!'; console.log(str.includes('World')); // true
endsWith()
: 이 메서드는 문자열이 특정 부분 문자열로 끝나는지 여부를 확인합니다. 끝나면 true
를 반환하고, 그렇지 않으면 false
를 반환합니다.
javascriptconst str = 'Hello, World!'; console.log(str.endsWith('World!')); // true
startsWith()
: 이 메서드는 문자열이 특정 부분 문자열로 시작하는지 여부를 확인합니다. 시작하면 true
를 반환하고, 그렇지 않으면 false
를 반환합니다.
javascriptconst str = 'Hello, World!'; console.log(str.startsWith('Hello')); // true
댓글 0