endsWith

String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
Example:
console.log("hi this ends with a dollar".endsWith('dollar')); //true

Description

adds endsWith method to the prototype of String. Returns boolean

Details

Double click on the code to select all.

 

;