PROWAREtech








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