Map constructor IE11


#1

Hello,

I'm passing array to Map constructor like this:

let arr = [['a', 1], ['b', 2]];
let map = new Map(arr);

IE11 returns empty object.
Documentation says that passing iterable to constructors in IE11 is supported only as arrays of key/value pairs, but its not working. Anyone have this issue?


#2

Where is the documentation that says that IE11 accepts an iterable as the constructor?
With IE11, I don't see that information in the documentation.
https://docs.microsoft.com/en-us/scripting/javascript/reference/map-object-javascript


#3

I've found it on MDN docs.


Now I know I can't always rely on MDN.


#4

MDN is specific to Firefox, being from the Mozilla Development Network. Most browsers behave the same or similar, as Firefox tries to stay as close as it reasonably can to the specs, but sometimes there are differences/improvements, such as with this.


#5

It works for me.


#6

Using var in IE11 is different Jeff from using let.

Can it work in IE11 when using var?

var arr = [['a', 1], ['b', 2]];
var map = new Map(arr);

Yes, that on testing works with IE11.


#7

I have to retract my "it works for me" statement. I happened to be on the google homepage when I ran that in the console, but I discovered the same code doesn't work in the console on other pages. It looks like it only worked for me before because google polyfilled/monkey patched the implementation of Map on their site.

I'm more disappointed to say that perhaps MDN did indeed have wrong information in this case. They claimed IE11's Map could be initialized with an array of key/value pairs, but that doesn't seem to be the case.


#8

Thanks Jeff for helping to explain that mystery.

In summary:

IE11 doesn't like using let or const from the console, even though you can use them from code
IE11 doesn't support Map constructor arguments.

Full details on the ES6 support from IE11 is found at the ES6 compat table


#9

Thank you Jeff for submitting an issue to MDN about the IE11 map.


closed #10

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.