user13286
user13286

Reputation: 3075

Javascript syntax error in IE11 for sort function

I am sorting an Array with Javascript and it is working fine in Chrome, Firefox, Safari but in IE11 I am getting a syntax error. Anyone know what could be causing this? Here's my sort function:

arr.sort((a, b) => b - a);

Upvotes: 0

Views: 703

Answers (1)

Aluan Haddad
Aluan Haddad

Reputation: 31863

Internet Explorer 11 does not support the ES2015 feature Arrow Functions.

Either use the function syntax or incorporate a transpiler such as Babel or TypeScript into your toolchain.

Your code as transpiled by Babel

Your code as transpiled by TypeScript

Upvotes: 1

Related Questions