Syntax error in IE using ES6 arrow functions

前端 未结 2 1954
不知归路
不知归路 2020-11-29 12:10

I have this piece of JavaScript code

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

This works fine in Firefox an

2条回答
  •  一生所求
    2020-11-29 12:51

    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?

提交回复
热议问题