Google Chrome - JavaScript版本 [英] Google Chrome - JavaScript version

查看:160
本文介绍了Google Chrome - JavaScript版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Chrome支持哪种版本的JavaScript与Mozilla Firefox相关?换句话说,Chrome是否支持Firefox支持的JavaScript 1.6,1.7或1.8版本,或者它们的一些组合呢?

Chrome会执行标记为javascript1.7的Javascript,它不支持JS1.7的特性,比如let范围变量操作符。



这段代码将运行在Firefox 3.5,但不是在使用V8的Chrome上:

 < script language =javascripttype =application / javascript; version = 1.7 > 
函数foo(){let a = 4;警报(A); }; FOO();
< / script>

如果您将语言更改为javascript1.7并省略该类型,则不会运行Firefox 3.5中的JS 1.7功能。类型部分是必要的。



这似乎与一般的WebKit错误有关, https://bugs.webkit.org/show_bug.cgi?id=23097 ; Chrome可能会模仿Safari的行为,即使它使用了一个不同的引擎。



当被问及关于支持JS 1.8功能的问题时,V8团队表示他们试图跟踪在Safari中使用的版本,这两个浏览器。


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 supports or some combination of them?

解决方案

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.

这篇关于Google Chrome - JavaScript版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆