Es6-string-method-endswith
提供:Dev Guides
ES6-新しいStringメソッドendsWith
この関数は、ストリングが別のストリングの文字で終わるかどうかを判別します。
構文
str.endsWith(matchstring[, position])
パラメーター
- matchstring -文字列が終わる必要がある文字。 大文字と小文字が区別されます。
- 位置-マッチ文字列に一致する位置。 このパラメーターはオプションです。
戻り値
文字列が一致文字列の文字で終わる場合は true 。それ以外の場合は、 false 。
例
var str = 'Hello World !!! ';
console.log(str.endsWith('Hello'));
console.log(str.endsWith('Hello',5));
出力
false
true