v8 何时实现 ECMAScript 5?

发布于 2024-11-09 11:31:45 字数 1396 浏览 5 评论 0原文

我注意到 v8 在 ECMAScript 第五版问题上相当沉默。

V8 实现 ECMA-262 第 3 版中指定的 ECMAScript,并在 Windows XP 和 Vista、Mac OS X 10.5 (Leopard) 以及使用 IA-32 或 ARM 处理器的 Linux 系统上运行。

即使错误跟踪器似乎也很安静...

一个错误,您可以找到提交者写下以下内容:

V8 是 ECMAScript 的实现,而不是 JavaScript。后者是 Mozilla 制作的 ECMAScript 的非标准化扩展。 V8 旨在与 JSC(WebKit/Safari 中的 ECMAScript 实现)实现插件兼容。因此,它实现了许多 ECMAScript 的非标准扩展,这些扩展也包含在 JSC 中,其中大多数也包含在 Mozilla 的 JavaScript 语言中。没有计划将 JSC 中没有的非标准功能添加到 V8 中。

有趣的是,他在 2010 年 10 月 8 日写道,当时 ECMAScript 5 于 2009 年 12 月发布,两个月前,Javascript 1.8.5(ECMAScript 5 的超集)发布了。

那么问题仍然是 Google 何时会更新 v8 以在 ECMAScript 第五版上运行?是否有计划升级到最新的 ECMAScript 标准化?

I noticed that v8 is rather mute on the issue of ECMAScript 5th edition.

V8 implements ECMAScript as specified in ECMA-262, 3rd edition, and runs on Windows XP and Vista, Mac OS X 10.5 (Leopard), and Linux systems that use IA-32 or ARM processors.

Even the bug tracker seems quiet...

On one bug you can find a commiter writing this:

V8 is an implementation of ECMAScript, not JavaScript. The latter is a non-standardized extension of ECMAScript made by Mozilla. V8 is intended to be plug-in compatible with JSC, the ECMAScript implementation in WebKit/Safari. As such it implements a number of non-standard extensions of ECMAScript that are also in JSC, and most of these are also in Mozilla's JavaScript languages. There is no plan to add non-standard features that are not in JSC to V8.

Interestingly enough he wrote that on Oct 8, 2010, when ECMAScript 5 was published on December 2009, and two months earlier Javascript 1.8.5 -- a superset of ECMAScript 5 -- was released.

So the question remains when will Google update v8 to run on ECMAScript 5th edition? Is there even a plan to upgrade to the latest standardization of ECMAScript?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖个坑埋了你 2024-11-16 11:31:45

ECMAScript 5 实际上就是这样设计的,因此实现不需要“更新即可在其上运行”

现有行为几乎没有变化,但主要是 ES5 添加了新的原生对象(例如 Object.createArray.prototype.mapString.prototype.trim 等)并标准化了一些现有的事实上的功能(从无处不在的“字符串文字中的行终止符”、“字符串上的属性访问”和“间接求值行为”到不太流行的“访问器”和数组/字符串扩展)。

行为上最大的变化——严格模式——出于同样的原因被选择加入;使从 ES3 到 ES5 的过渡不那么痛苦。

话虽如此,V8 确实实现了 ES5 的大部分功能,包括严格模式(最近添加的功能之一)。

如果你看看我的 ES5 兼容性。表你可以看到在 Chrome 中实现的 ES5 功能——它应该与 V8 密切(而且我认为——完全)相关。

您还可以看到,对严格模式的支持主要在 Chrome 中实现,这意味着它应该也可以在 V8 中。为了仔细检查,我刚刚在控制台(v8 v3.2.3.1)中运行了这段代码并得到了预期的 SyntaxError:

> (function(){"use strict"; with({x:1}) return x})()
(shell):1: SyntaxError: Strict mode code may not include a with statement
(function(){"use strict"; with({x:1}) return x})()
                          ^^^^

所以你已经得到了它。 V8 绝对实现了大部分 ES5 功能,包括严格模式;)

ECMAScript 5 was actually designed in such way so that implementations don't need to be "updated to run" on it.

There are few changes in existing behavior but mainly ES5 adds new native objects (e.g. Object.create, Array.prototype.map, String.prototype.trim, etc.) and standardizes some of the existing de-facto features (from ubiquitous "line terminators in string literals", "property access on strings", and "indirect eval behavior" to less popular "accessors" and array/string extensions).

The biggest change in behavior — strict mode — was made opt-in for the very same reason; to make transition from ES3 to ES5 less painful.

Having said that, V8 does implement a noticeable chunk of ES5 features, including strict mode (one of the recent additions).

If you look at my ES5 compat. table you can see ES5 features implemented in Chrome — which should closely (and I would think — completely) correlate to V8.

You can also see that support for strict mode is largely implemented in Chrome which means that it should be in V8 as well. To double check, I just ran this code in console (v8 v3.2.3.1) and got SyntaxError as expected:

> (function(){"use strict"; with({x:1}) return x})()
(shell):1: SyntaxError: Strict mode code may not include a with statement
(function(){"use strict"; with({x:1}) return x})()
                          ^^^^

So there you have it. V8 definitely implements majority of ES5 features, including strict mode ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文