JavaScript문자열endsWith

endsWith문자열

문자열이 지정 문자열로 끝나는지 확인합니다.

문법

str.endsWith(searchStr, endPos?)

예제

아래 값을 입력하면 예제에 즉시 반영됩니다.

const
filename
console
endsWith
const filename = "report.pdf";
console.log(filename.endsWith(".pdf"));   // true
console.log(filename.endsWith(".txt"));   // false