String.prototype.endsWith

Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endIndex – length(this). Otherwise returns false.

Syntax

endsWith(searchString, endIndex?)

Parameters

Return value

true if the given searchString occurs at the end of this string, otherwise false.

Examples

"spring".endsWith("ing")
true