SCRIPT438 Error in Internet Explorer 11

前端 未结 4 2106
野的像风
野的像风 2020-12-28 18:06

I\'ve been working on JavaScript lately, and everything was fine until I opened my page in IE11. as per Mozilla website .forEach is supported f

4条回答
  •  自闭症患者
    2020-12-28 18:19

    if (typeof Array.prototype.forEach != 'function') {
    Array.prototype.forEach = function (callback) {
        for (var i = 0; i < this.length; i++) {
            callback.apply(this, [this[i], i, this]);
        }
     };
    }
    
    if (window.NodeList && !NodeList.prototype.forEach) {
        NodeList.prototype.forEach = Array.prototype.forEach;
     }  
    

提交回复
热议问题