Google Chrome - JavaScript version

后端 未结 6 1202
攒了一身酷
攒了一身酷 2020-12-08 03:57

Which version of JavaScript does Google Chrome support in relation to Mozilla Firefox? In other words, does Chrome support JavaScript 1.6, 1.7, or 1.8 which Firefox also su

相关标签:
6条回答
  • 2020-12-08 04:24

    Google Chrome supports up to Javascript 1.7:

    <script language="javascript1.7">alert(1.7);</script> - Alerts
    <script language="javascript1.8">alert(1.8);</script> - Doesn't alert
    
    0 讨论(0)
  • 2020-12-08 04:33

    While Chrome will execute Javascript marked as "javascript1.7", it does not support JS1.7 features like the "let" scoped variable operator.

    This code will run on Firefox 3.5 but not on Chrome using V8:

    <script language="javascript" type="application/javascript;version=1.7">
        function foo(){ let a = 4; alert(a); }; foo();
    </script>
    

    If you change language to "javascript1.7" and omit the type, it won't run with JS 1.7 features in Firefox 3.5. The type section is necessary.

    This seems to be related to a general WebKit bug, https://bugs.webkit.org/show_bug.cgi?id=23097; it may be that Chrome emulates the Safari behavior even though it uses a different engine.

    When asked about supporting JS 1.8 features, the V8 team said they were trying to track the version used in Safari so pages would act the same in both browsers.

    0 讨论(0)
  • 2020-12-08 04:35

    This thread is still relevant. As of 2012, Chrome supports most of Javascript 1.6, not including string and array generics. It supports none of 1.7. It supports reduce and reduceRight from 1.8, all of 1.8.1, and Getters and setters and all the non-version specific things listed on this page. This page is linked from the Mozilla Developer Network, which specifies the versions of javascript, found here.

    0 讨论(0)
  • 2020-12-08 04:43

    Here's a simple Javascript 1.6 feature Chrome (and V8 users, like node.js) won't run: for each … in

    for each (variable in object)
      statement
    

    As it is JS 1.5 (per J c's answer) is the only version Chrome claims to completely implement.

    In fact the Chrome team has mostly aimed for compatibility with Safari (most prominent Webkit user at the time), and refused features on those grounds.

    0 讨论(0)
  • 2020-12-08 04:48

    Google Chrome uses the V8 javascript engine, which currently states that it implements ECMA-262, 3rd edition. This would imply it supports at least version 1.5.

    0 讨论(0)
  • 2020-12-08 04:48

    This is an old thread, however here goes. Google Chrome does not respond to the following

    function foo(){
      let a = 4;
      alert(a);
    }
    foo();
    

    hence it does not support JavaScript 1.7

    0 讨论(0)
提交回复
热议问题