EndsWith function for Javascript

This snippet will give you the EndsWith function for Javascript.

Sample Javascript

String.prototype.endsWith = function(text) {
	return (this.indexOf(text) === (this.length-text.length));
};

Please Share us:
Please rate this snippet

2 thoughts on “EndsWith function for Javascript

Leave a Reply