Why is forEach () not working in an iframe in IE11?
This question was closed as off-topic, so I noted the missing information.
Specific problem or bug plus shortest code:
The code below doesn't work in IE11 if it's in the iframe of certain websites. ("Specific" is not specific, but I don't have a public demo. I can't do this until I find the reason in my personal code. However, the question is specific enough to give an expert answer that why I asked SO instead of the lengthy debugging process without any idea.)
['a', 'b'].forEach(function(elem){console.log(elem);});
error says that the array does not support the forEach method.
Desired behavior:
The forEach () method executes the provided function once per array element. - MDN
" IE11 uses Quirks mode emulation unless the top-level page is in Edge mode." - MSDN
In this mode, arrays do not support the forEach method.
Use a simple for loop or write this right after the parent's title tag
<meta http-equiv="X-UA-Compatible" content="IE=edge" />