PROWAREtech








JavaScript: IE11 String.endsWith() Prototype/Function
Create the String.endsWith() prototype for Internet Explorer 11.
Still developing for IE11? Well, this prototype returns true when the string ends with the argument.
if (!String.prototype.endsWith) {
String.prototype.endsWith = function (text) {
return this.indexOf(text, this.length - text.length) != -1;
};
}
Using the above code snippet:
if (!String.prototype.endsWith) {
String.prototype.endsWith = function (text) {
return this.indexOf(text, this.length - text.length) != -1;
};
}
alert("this is a test".endsWith("test"));
Comment