Object doesn’t support property or method ‘forEach’

To make NodeList.forEach() method work on internet explorer, you will have to add the following polyfill in your application.

(function () {
    if ( typeof NodeList.prototype.forEach === "function" ) return false;
    NodeList.prototype.forEach = Array.prototype.forEach;
})();

If this polyfill helped in your work, let us how it helped you by your comments !

You may also like...

  • Mohamad Al-Baz

    Yes. Totally did the trick.. Thumbs Up !

  • Justin Oneill

    Thanks a TON!! This totally fixed my Microsoft EDGE bug!

  • Mohamedmusammil Shaffi

    Thanks. Its working fine. As expected. Thank you so much.

  • http://danielzuzevich.com/ Daniel Zuzevich

    Used this and another in conjunction, and it works.

    (function () {
    if ( typeof NodeList.prototype.forEach === “function” ) return false;
    NodeList.prototype.forEach = Array.prototype.forEach;
    })();

    if (!Array.prototype.forEach) {
    Array.prototype.forEach = function(fn, scope) {
    for(var i = 0, len = this.length; i < len; ++i) {
    fn.call(scope, this[i], i, this)
    }
    }
    }

    Just using your code doesn't work. Needed to extend the Array prototype.

  • Gorm Kjeldsen

    Thanks a lot. Worked like a charm, but damn, I’m sick of IE..

  • http://stevemeisner.us/ Stephen Meisner

    Beautiful.

  • qayyumabro

    You saved a lot of time.

  • Riaz_Sulaiman

    yeah..it worked…Thumbs Up!!!

  • Frank Conijn

    Even simpler:

    if (Array.prototype.forEach)
    NodeList.prototype.forEach = Array.prototype.forEach;

  • Jake Nort

    Works well. Thank you