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...

10 Responses

  1. Mohamad Al-Baz says:

    Yes. Totally did the trick.. Thumbs Up !

  2. Justin Oneill says:

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

  3. Mohamedmusammil Shaffi says:

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

  4. 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.

  5. Gorm Kjeldsen says:

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

  6. qayyumabro says:

    You saved a lot of time.

  7. Riaz_Sulaiman says:

    yeah..it worked…Thumbs Up!!!

  8. Frank Conijn says:

    Even simpler:

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

  9. Jake Nort says:

    Works well. Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *