ECMA 6 Not working although experimental js is enabled

前端 未结 3 1355
慢半拍i
慢半拍i 2020-12-02 00:27

I have the latest Chrome version (45 and also Chrome Canary which is in version 47), both with the Experimental Javascript flag enabled. I want to use ECMA6, but it doesn\'t

3条回答
  •  一个人的身影
    2020-12-02 01:28

    Here are a couple feature lists that tell you what features work in Chrome 45.

    Chrome Feature Status: https://www.chromestatus.com/features

    ES6 compatibility matrix: https://kangax.github.io/compat-table/es6/

    What you will find is that many features such as the class sugar syntax work fine in Chrome 45, but require strict mode in order to be enabled.

    For example, if you run this jsFiddle that uses class in Chrome 45 or greater, it will work: http://jsfiddle.net/jfriend00/xd56k8n3/. If you run it outside of strict mode, it reports Uncaught SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode.

    Modules do not look like they yet have support in any browser.


    FYI, one common way to write code now in ES6 is to use a transpiler like Babel or Traceur that you feed ES6 code into and it converts it to ES5-compatible code that runs in current browsers. You get to write in ES6, but have compatibility with current browsers.

提交回复
热议问题