endWith()

更新日: 2018-09-14

is.endWith(value:string, target:string)

渡された文字列が指定した文字で終わっているかどうかを判定します。

インターフェース:
not
is.endWith('yeap', 'ap');
=> true

is.endWith('nope', 'no');
=> false

is.not.endWith('nope not that', 'not');
=> true

is.endWith('yeap that one', 'one');
=> true

デモ

変数を判定してconsole.logを出力します。

JavaScript
var string1 = 'yeap',
    substr1 = 'ap',
    string2 = '全角文字列でも判定可能です。';
    substr2 = 'です。';
if (is.endWith(string1, substr1)) {
  console.log("'yeap'は'ap'で終わります。");
}
if (is.endWith(string2, substr2)) {
  console.log('全角文字列でも判定可能です。');
}


© 2014-2016 Aras Atasaygin Released under the MIT license

このコンテンツはAras Atasaygin(arasatasaygin)によるis.jsドキュメントを翻訳/改変したものです。