Use indexOf method to check string ends - Node.js String

Node.js examples for String:String End

Description

Use indexOf method to check string ends

Demo Code


String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

Related Tutorials