如何警告浏览器的受支持的EcmaScript版本? [英] How can I alert supported EcmaScript version of the browser?

查看:115
本文介绍了如何警告浏览器的受支持的EcmaScript版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以警告运行我的JavaScript的当前环境的受支持EcmaScript版本?

Is there a way to alert the supported EcmaScript version of the current environment where I run my JavaScript?

推荐答案

简短回答:否。

简短回答:首先,浏览器未实现ECMAScript,而是基于该规范(例如,用于Firefox的JavaScript,用于Microsoft的JScript)。通常,他们可以实现部分标准,并在该语言的下一版本中完善该标准(例如,有关ES5的JavaScript 1.8 / 1.8.1 / 1.8.5中发生过这种情况,请参见 JavaScript的新功能)。

Long answer: First of all, browsers doesn't implement ECMAScript but a language based on that specification (e.g. JavaScript for Firefox, JScript for Microsoft). Often, they can implement part of the standard, and complete the standard in a next version of the language (it happened in JavaScript 1.8 / 1.8.1 / 1.8.5 about ES5 for example, see New in JavaScript).

另外,他们可以预期标准:请参见关于... of let ,这是Mozilla多年来以来一直拥有的,这是ES6的一部分。

Plus, they could anticipate the standard: see for...of or let, that Mozilla has since years, that are part of ES6.

因此,您无法真正说出您的环境支持哪种ES版本;您可以做的就是测试您感兴趣的功能,然后使用它们。在大多数情况下,我们会尽可能使用垫片来模拟该功能,例如 ES5

So, you can't really say what ES version is supported by your environment; what you can do is testing the functionality you are interested in, and use them. In most of the case, we apply a shim, where is possible, to emulate that functionality, like for ES5.

这篇关于如何警告浏览器的受支持的EcmaScript版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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