JavaScript 문자열 끝()
예
문자열이 "world"로 끝나는지 확인:
let text = "Hello world";
let result = text.endsWith("world");
let text = "Hello World";
let result = text.endsWith("world");
아래에 더 많은 예가 있습니다.
정의 및 사용
문자열 이
지정된 문자열로 끝나는 경우 endsWith()
메서드가 반환 됩니다.true
그렇지 않으면 반환합니다 false
.
메서드 는 endsWith()
대소문자를 구분합니다.
방법 도 참조하십시오 startswith()
.
통사론
string.endsWith(searchvalue, length)
매개변수
Parameter | Description |
searchvalue | Required. The string to search for. |
length | Optional. The length of the string to search. Default value is the length of the string. |
반환 값
유형 | 설명 |
참이나 거짓 | true 문자열이 값으로 끝나면 그렇지 않으면 false . |
더 많은 예
문자열의 첫 11자가 "world"로 끝나는지 확인합니다.
let text = "Hello world, welcome to the universe.";
text.endsWith("world", 11);
브라우저 지원
endsWith()
ECMAScript6(ES6) 기능입니다.
ES6(JavaScript 2015)은 모든 최신 브라우저에서 지원됩니다.
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
endsWith()
Internet Explorer 11(또는 이전)에서는 지원되지 않습니다.