Home >Web Front-end >JS Tutorial >Finally solved the problem that IE8 does not support the indexOf method of array_javascript skills
Here’s the solution I found:
Before using the indexOf method, execute the following js. The principle is that if it is found that the array does not have an indexOf method, this method will be added.
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from = len;
for (; from < len; from )
{
if (from in this &&
this[from] === elt)
return from;
}
Return -1;
};
}