Search code examples
javascriptinternet-explorercross-browserarrow-functions

Update an ES6 Arrow Function such that it works on IE?


I am stuck on making this polyfill code for IE which has the following code running.

var filterArrayGAME = $("#locGAME span").get().map(el => el.textContent)

Is there a way to write this in such a manner that we do not encounter an issue while trying to view this page on Internet Explorer ?


Solution

  • I suggest you use Babel.js to convert your ES6 code to ES5 code Which is supported by the IE browser.

    Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.

    Here is the conversion done by Babel:

    var filterArrayGAME = $("#locGAME span").get().map(function (el) {
      return el.textContent;
    });
    

    Reference:

    Babel.js