Hi Everyone,
I am working with one of the projects to make it compatible with IE8. I got this issue as I have shown below, will you please give me any alternate way or suggestion to use these functions in Javascript?
SCRIPT438: Object doesn't support property or method 'includes'
SCRIPT436: Object doesn't support property or method 'indexOf'
I tried this
- function includes(container, value) {
- var returnValue = false;
- var pos = container.indexOf(value);
- if (pos >= 0) {
- returnValue = true;
- }
- return returnValue;
- }
- includes([1,2,3],2)
- includes([1,2,3],'a')
Also tryed
- if (!String.prototype.includes) {
- String.prototype.includes = function (str) {
- return this.indexOf(str) !== -1;
- }
- }
but not work well for IE8.
Will anyone please help me.