*startsWith()
메서드는 어떤 문자열이 특정 문자로 시작하는지 확인하여 결과를 true
혹은 false
로 반환합니다.*
대소문자를 구분합니다.
// str.startsWith(searchString: string, position: number): boolean
startsWith(searchString);
startsWith(searchString, position);
문자열의 시작 시점에서 탐색할 문자열.
정규 표현식이 올 수 없습니다.
optional
searchString 을 탐색할 위치, (기본값은 0)
대상 문자열이 주어진 문자로 시작하면 true
, 아니면 false
const str = "To be, or not to be, that is the question.";
console.log(str.startsWith("To be")); // true
console.log(str.startsWith("not to be")); // false
console.log(str.startsWith("not to be", 10)); // true