Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with Array.map() in IE11

I have this code:

var labelsPrint= new Array();

var vector = labelsPrint.map((el) => el.id);

IE11 give me a error, because lost the datas. Do you know an other way for make this .map?

like image 278
Manu Avatar asked Jan 29 '16 10:01

Manu


People also ask

Does map work in IE11?

In order to free up resources to deliver customer-requested features available to modern browsers, Google Maps Platform is ending support for Internet Explorer 11. Microsoft ended support for IE11 in 2021 and encouraged migration to Microsoft Edge.

Can we use map on array?

map() can be used to iterate through objects in an array and, in a similar fashion to traditional arrays, modify the content of each individual object and return a new array. This modification is done based on what is returned in the callback function.

What is the purpose of array map () in JavaScript?

JavaScript | Array map() Method The map() method in JavaScript creates an array by calling a specific function on each element present in the parent array. It is a non-mutating method. Generally map() method is used to iterate over an array and calling function on every element of array.

What is array prototype map () useful for?

Array.prototype.map() The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.


1 Answers

IE11 has ES5, not ES6

var vector = labelsPrint.map(function (el) { return el.id; });
like image 136
Nina Scholz Avatar answered Oct 13 '22 05:10

Nina Scholz