IE syntax error using ES6 functions arrow

I have this piece of JavaScript code

price = price.replace(/(.*)\./, x => x.replace(/\./g,'') + '.')

This works fine in Firefox and Chrome, however IE gives me a syntax error pointing to =>in my code.

Is there a way to use ES6 arrow syntax in IE?

+4
source share
2 answers

IE does not support ES6, so you have to stick with the original way of writing such functions.

price = price.replace(/(.*)\./, function (x) {
  return x.replace(/\./g, '') + '.';
});

Also related: When will ES6 be available in IE?

+15
source

Internet explorer . , .

- :

price = price.replace(/(.*)\./, function (x) {
    x.replace(/\./g,'') + '.';
}

.

+3

Source: https://habr.com/ru/post/1658097/


All Articles