Closed Bug 1429791 Opened 6 years ago Closed 6 years ago

IE support on Array.prototype.forEach() page is wrong

Categories

(Developer Documentation Graveyard :: JavaScript, defect, P1)

All
Other
defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: jpkant, Unassigned)

References

()

Details

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: unspecified
 Technical Contact: 

:: Details

When I used forEach() in IE 11, I got the error `SCRIPT438: Object doesn't support property or method 'forEach'`. Supported version on the page says 9 when the method doesn’t work at all.
Could you paste a jsfiddle/codepen example where you reproduce the issue?
I've tried the following https://codepen.io/anon/pen/EoLNZW with an IE11 and it works fine (you can open the console with the button located in the bottom/left corner of the page).
Flags: needinfo?(jpkant)
Well, it looks like this is an issue with DOM-related objects then. I got the error while trying to loop through `document.querySelectorAll("p")` and print the `innerHTML`s.

https://codepen.io/jkantner/pen/ypEoMq
Priority: P5 → P1
Then, this is not due about the support of forEach for Arrays but for NodeList (the type of object returned by querySelectorAll). As written on https://developer.mozilla.org/en-US/docs/Web/API/NodeList#Browser_compatibility, IE doesn't implement generic iteration methods for NodeList.

@jpkant: if you edit your codepen to directly use an array instead of document.querySelectorAll, you'll see the console populated with the results instead of the error.

All in all, I think both forEach and NodeList page provide the right compatibility data, feel free to comment.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Flags: needinfo?(jpkant)
Resolution: --- → WORKSFORME
Okay, I see. Then partial support should have been noted somewhere.
Partial support is indicated on the Browser Compatibility section of the NodeList article(cf. https://developer.mozilla.org/en-US/docs/Web/API/NodeList#Browser_compatibility ). This table contains two rows: one for the basic behavior and a second one about iteration methods. This second row states that IE doesn't support (yet) forEach to iterate through a NodeList object.
You need to log in before you can comment on or make changes to this bug.