简体   繁体   English

是否可以使用Ecmascript5脚本中的Ecmascript6脚本而不进行转译?

[英]Is it possible to use an Ecmascript6 script out of an Ecmascript5 script without transpiling?

I've written some modules in Ecmascript6 for a system which is written in Ecmascript5. 我已经用Ecmascript6编写了一些用Ecmascript5编写的系统模块。 The modules are working properly as they should as well as the rest of the system. 这些模块以及系统的其余部分均正常运行。

Is it know possible for the system to use these new modules without transpiling them back into ES5? 是否知道系统可以使用这些新模块而无需将它们重新编译回ES5? This question is not meant to be for a specific project or setup, more like a general possiblity working with ES5 and ES6. 这个问题不是针对特定项目或设置的,更像是与ES5和ES6一起工作的一般可能性。

Thank's for the help. 谢谢您的帮助。

It all depends on the platform you are going to run it. 这完全取决于您要运行它的平台。 If your platform supports ES 2016, you won't have any problem running it. 如果您的平台支持ES 2016,则运行它不会有任何问题。

Example: Chrome supports latest ECMA Script features, so all your ECMA 6 and ECMA 7 functions will run properly, While older Internet Explorer does not support ECMA 6. So you won't be able run your codes there. 示例:Chrome支持最新的ECMA脚本功能,因此您的所有ECMA 6和ECMA 7功能将正常运行,而较早的Internet Explorer不支持ECMA6。因此,您将无法在其中运行代码。

So it doesn't matter if your module was earlier written in ECMA 2015 or ECMA 2016, All latest ECMA script versions are backward compatible. 因此,无论您的模块先前是用ECMA 2015还是ECMA 2016编写的,都没有关系。所有最新的ECMA脚本版本都向后兼容。 And that's the beauty of JavaScript. 这就是JavaScript的美。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM