Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error in IE using ES6 arrow functions

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 an syntax error pointing at => in my code.

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

like image 584
Michael Tot Korsgaard Avatar asked Oct 18 '16 13:10

Michael Tot Korsgaard


1 Answers

IE doesn't support ES6, so you'll have to stick with the original way of writing functions like these.

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

Also, related: When will ES6 be available in IE?

like image 67
roberrrt-s Avatar answered Sep 22 '22 21:09

roberrrt-s