0

How do I use ... within IE with the code below? I'm new to using ... and it's hard for me to convert it so that it works with IE11.

I'm using angularJS here, but the code below isn't working on IE and it's throwing a syntax error at ...new. Sadly, I can't use babel in this instance.

scope.model.locations = res.sort(function(a, b) {
  (a.locationName > b.locationName) ? 1: -1
});
scope.model.jobCategories = [...new Set(scope.model.jobCategories)];
Run_Script
  • 2,487
  • 2
  • 15
  • 30
Charles L.
  • 1,844
  • 2
  • 34
  • 56
  • Try -> `Array.from(new Set(scope.model.jobCategories))` – Keith Jan 14 '20 at 17:01
  • 2
    `Array.from` [isn't supported in IE11](http://kangax.github.io/compat-table/es6/#test-Array_static_methods) – Phix Jan 14 '20 at 17:03
  • 2
    All the line does is de-duplicate jobCategories, so you could look at alternatives for de-duplicating an array-> eg.. https://stackoverflow.com/questions/9229645/remove-duplicate-values-from-js-array – Keith Jan 14 '20 at 17:15
  • [IE11 doesn't support constructor arguments to `Set` either](http://kangax.github.io/compat-table/es6/#test-Set_constructor_arguments). – Heretic Monkey Jan 14 '20 at 20:04

0 Answers0