String.prototype.endsWith() - mkloubert/jsToolbox GitHub Wiki

String.prototype.endsWith(str) method

Checks if the string ends with a specific expression.

Syntax

String.prototype.endsWith(str);

Parameters

Name Type Description
str String The expression that should be checked.

Result

Ends with expression or not.

Examples

var s = '5979';

// (true)
var res1 = s.endsWith('9');
// (false)
var res2 = s.endsWith('MK');