How to convert an HTML Collection into Array in Firefox and IE

I need to convert an array-like object into a real array. I’m using getElementsByTagName to get the list of elements.

var tablerow = document.body.getElementsByTagName('tr');

var tablerowArr =

In Chrome, tablerowArr correctly converts into an array with the same number of items. However in Firefox and IE, it has 0 items.

What am I doing incorrectly?

Note: I am doing this so I can use

tablerowArr.forEach(function (value, i) { stuff }

Source: cross-browser

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.