320x100
320x100

기본 문법

str.endsWith(searchString[, length])

- searchString 

: 끝나는지 찾을 문자열

 

- length

: 찾고자 하는 문자열의 길이 값

: 기본 값으로는 문자열 전체 길이

 

- 반환 값

: 문자열의 끝이 주어진 문자열로 끝나면 true / false

 

 

var str = 'To be, or not to be, that is the question.';

console.log(str.endsWith('question.')); // true
console.log(str.endsWith('to be'));     // false
console.log(str.endsWith('to be', 19)); // true

 

 

 

 

Refference

 

String.prototype.endsWith() - JavaScript | MDN

The endsWith() 메서드를 사용하여 어떤 문자열에서 특정 문자열로 끝나는지를 확인할 수 있으며, 그 결과를 true 혹은 false로 반환한다.

developer.mozilla.org

 

300x250
728x90