JavaScript文字列endsWith
concat

endsWith文字列

includes

文字列が指定した文字列で終わるか確認します。

構文

str.endsWith(searchStr, endPos?)

使用例

下記の値を入力するとサンプルに即時反映されます。

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