Es6-string-prototype-endswith

提供:Dev Guides
移動先:案内検索

ES6-String.prototype.endsWith()

この関数は、文字列が指定した文字列の文字で終わるかどうかを判別し、trueまたはfalseを返します。

構文

以下で説明する構文は、* String.prototype.endsWith()用です。ここで、 *searchString は、この文字列の末尾で検索される文字です。 length はオプションのパラメーターです。 文字列の長さを表します。

str.endsWith(searchString[, length])

<script>
   let company = 'finddevguides'
   console.log(company.endsWith('Point'));
   console.log(company.endsWith('Tutor',5))//5 is length of string
</script>

上記のコードの出力は以下のようになります-

true
true