IE8 支持哪些 Javascript 版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2714694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which Javascript version(s) does IE8 supports?
提问by MatteoSp
According to Wikipedia, IE8 only supports Javascript 1.5. So they are saying IE8 completely ignores Javascript versions 1.6, 1.7, 1.8 and 1.9.
根据维基百科,IE8 只支持 Javascript 1.5。所以他们说 IE8 完全忽略了 Javascript 版本 1.6、1.7、1.8 和 1.9。
Should I trust? Is it true?
我应该相信吗?这是真的吗?
回答by CMS
Well, actually the IE implementation is called JScript, JavaScript(TM) is the implementation of Mozilla.
嗯,实际上 IE 实现称为JScript,JavaScript(TM) 是 Mozilla 的实现。
JScript and JavaScript are two ECMAScript-based dialects.
JScript 和 JavaScript 是两种基于ECMAScript的方言。
JavaScript 1.5 conforms with the ECMAScript 3rd Edition Standard, the subsequent versions, JS 1.6, 1.7 and 1.8 introduce language features that are out of that standard edition, often called Mozilla Extensions.
JavaScript 1.5 符合ECMAScript 3rd Edition Standard,后续版本 JS 1.6、1.7 和 1.8 引入了该标准版之外的语言特性,通常称为Mozilla 扩展。
That's why JScript doesn't have any of these features, because they are not part of the ECMA Standard.
这就是 JScript 没有任何这些功能的原因,因为它们不是 ECMA 标准的一部分。
回答by Pekka
This test taken from herereturns 1.3in my Internet Explorer 8 64-bit.
从这里进行的这个测试1.3在我的 64 位 Internet Explorer 8 中返回。
<SCRIPT Language="JavaScript1.3">
jsver = "1.3";
</SCRIPT>
<SCRIPT Language="JavaScript1.4">
jsver = "1.4";
</SCRIPT>
<SCRIPT Language="JavaScript1.5">
jsver = "1.5";
</SCRIPT>
<SCRIPT Language="JavaScript1.6">
jsver = "1.6";
</SCRIPT>
<SCRIPT Language="JavaScript1.7">
jsver = "1.7";
</SCRIPT>
<SCRIPT Language="JavaScript1.8">
jsver = "1.8";
</SCRIPT>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
document.write("<B>Your browser supports JavaScript version " + jsver + ".</B>")
</SCRIPT>
</body>
</html>
回答by bobince
IE doesn't support JavaScript at all. “JavaScript” specifically refers to Mozilla's implementation of the ECMAScript standard. This standard was originally derived from Netscape/Mozilla's work on the language, but they have since diverged. IE's implementation of ECMAScript is called “JScript”, and it does not support many of the extensions Mozilla have made.
IE 根本不支持 JavaScript。“JavaScript”特指 Mozilla 对 ECMAScript 标准的实现。该标准最初源自 Netscape/Mozilla 在该语言方面的工作,但此后它们发生了分歧。IE 的 ECMAScript 实现称为“JScript”,它不支持 Mozilla 所做的许多扩展。
The version of ECMAScript IE aims for is the Third Edition standard, which is also version JavaScript 1.5 was aimed at, which is why they're considered similar. The JavaScript engines of Opera, Safari and Chrome all target this same version; whilst all the implementations have bugs that mean they don't quite exactly meet the spec, in general ECMAScript Third Edition is a solid baseline for what works today.
ECMAScript IE 的目标版本是第三版标准,这也是 JavaScript 1.5 的目标版本,这就是为什么它们被认为是相似的。Opera、Safari 和 Chrome 的 JavaScript 引擎都针对同一个版本;虽然所有的实现都有错误,这意味着它们并不完全符合规范,但总的来说,ECMAScript 第三版是当今工作的可靠基准。
The next version of ECMAScript is the Fifth Edition, which was standardised recently. All browsers are picking up features from this spec and it is hoped it will become as widely-supported in the future. It does not align to any particular “JavaScript” version; it notably picks up some useful Stringand Arraymethods that were previously in JavaScript 1.5, but you won't find most of Mozilla's syntactical extensions to JS in the standard.
ECMAScript 的下一个版本是最近标准化的第五版。所有浏览器都从这个规范中选择功能,希望它在未来得到广泛支持。它不符合任何特定的“JavaScript”版本;它主要是拿起一些有用的String并且Array是在JavaScript 1.5以前的方法,但你不会找到最Mozilla的语法扩展,JS标准。
回答by Guffa
Yes, that is true (at least as far as which language features are supported). You can easily check this using some Javascript 1.6 code:
是的,确实如此(至少就支持哪些语言功能而言)。您可以使用一些 Javascript 1.6 代码轻松检查这一点:
alert([1,2,3].indexOf(2));
IE 8 throws an error.
IE 8 引发错误。
Note that IE 8 might support some of the features added in later versions of Javascript. IE contains a lot of stuff outside the standards, so it's likely that some of it happens to be the same as the later additions.
请注意,IE 8 可能支持在更高版本的 Javascript 中添加的某些功能。IE 包含了很多标准之外的东西,所以很可能其中一些恰好与后来的添加相同。

