0

As far as I know, this is valid EcmaScript6:

let obj = {foo: "foo", bar: "bar"}; 
let {foo, bar} = obj; // <- Syntax error here

Firefox runs this code just fine, but both Google Chrome and Chromium give me this error:

Uncaught SyntaxError: Unexpected token {

I know in firefox, scripts tags have to be flagged with "version=1.7" in the type attribute for this to work, but in Google Chrome this results in the script getting ignored. A normal script tag gives this error.

Does this mean this feature is not implemented in Google Chrome? Or am I missing something?

Setzer22
  • 1,589
  • 2
  • 13
  • 29

2 Answers2

3

That's right. Currently, it isn't supported yet.

https://devdocs.io/javascript/operators/destructuring_assignment

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
0

Although Chrome doesn't support some new features of ES6 (check this table to see what is already supported on different browsers), you can use a polyfill/plugins to enable certain features on Chrome. You can find polyfill and plugins on Babel. Just read through the plugins documentation and implement the ones you want.

Gabriel Ferraz
  • 592
  • 6
  • 26