endsWith (JavaScript)

ストリングがサブストリングで終わるかどうかを検査します。

定義場所

String (Standard - JavaScript)

構文

endsWith(str:string) : boolean
パラメータ 説明
str サブストリング。
戻り値 説明
boolean このストリングがサブストリングで終わる場合、またはサブストリングが空の場合は true。

(1) 次の比較は true です。
var cities = new String("Paris   Moscow   Tokyo");
if (cities.endsWith("Tokyo"))
	return "Ends with Tokyo";
else
	return "Does not end with Tokyo"
(2) 次の比較は false です。
cities = new String("Paris   Moscow   Tokyo");
if (cities.endsWith("TOKYO"))
	return "Ends with TOKYO";
else
	return "Does not end with TOKYO"