I am checking the URL to see if it contains or includes a ?
in it to control the hash pop state in the window. All other browsers aren’t having an issue, only IE.
This question and its answers led me to my own solution (with help from SO), though some say you shouldn't tamper with native prototypes:
// IE does not support .includes() so I'm making my own:
String.prototype.doesInclude=function(needle){
return this.substring(needle) != -1;
}
Then I just replaced all .includes()
with .doesInclude()
and my problem was solved.
I had a similar issue with an Angular project. In my polyfills.ts I had to add both:
import "core-js/es7/array";
import "core-js/es7/object";
In addition to enabling all the other IE 11 defaults. (See comments in polyfills.ts if using angular)
After adding these imports the error went away and my Object data populated as intended.
According to the MDN reference page, includes
is not supported on Internet Explorer. The simplest alternative is to use indexOf
, like this:
if(window.location.hash.indexOf("?") >= 0) {
...
}
I've used includes from Lodash
which is really similar to the native.
As in Internet Explorer, the javascript method "includes" doesn't support which is leading to the error as below
dijit.form.FilteringSelect TypeError: Object doesn't support property or method 'includes'
So I have changed the JavaScript string method from "includes" to "indexOf" as below
//str1 doesn't match str2 w.r.t index, so it will try to add object
var str1="acd", str2="b";
if(str1.indexOf(str2) == -1)
{
alert("add object");
}
else
{
alert("object not added");
}
IE11 does implement String.prototype.includes so why not using the official Polyfill?
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
} else {
return this.indexOf(search, start) !== -1;
}
};
}
Source: polyfill source