자바스크립트 문자열 startsWith()
예
위치 0에서 시작:
let text = "Hello world, welcome to the universe.";
text.startsWith("Hello");
위치 6에서 시작:
let text = "Hello world, welcome to the universe.";
text.startsWith("world", 7);
정의 및 사용
문자열 이
지정된 문자열로 시작하면 startsWith()
메서드가 반환 됩니다.true
그렇지 않으면 반환합니다 false
.
메서드 는 startsWith()
대소문자를 구분합니다.
방법 도 참조하십시오 endsWith()
.
통사론
string.startsWith(searchValue, start)
매개변수
Parameter | Description |
searchValue | Required. The string to search for. |
start | Optional. Start position. Default is 0. |
반환 값
유형 | 설명 |
참이나 거짓 | true 문자열이 값으로 시작하는 경우 반환 합니다. 그렇지 않으면 반환합니다 false . |
브라우저 지원
startsWith()
ECMAScript6(ES6) 기능입니다.
ES6(JavaScript 2015)은 모든 최신 브라우저에서 지원됩니다.
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
startsWith()
Internet Explorer 11(또는 이전)에서는 지원되지 않습니다.