简体   繁体   English

浏览器是否在内部将 ES6 转换为 ES5?

[英]Does browser internally transpile ES6 to ES5?

Since modern browsers support ES6.由于现代浏览器支持 ES6。 Do they internally transpiles ES6 down to ES5, and then execute the code?他们是否在内部将ES6 转换为 ES5,然后执行代码? Or they can understand ES6 code natively using C++ engine?或者他们可以使用 C++ 引擎原生地理解 ES6 代码?

If they can run ES6 directly, how does it ensure the behaviour of executing ES6 code is absolutely equivalent to executing the transpiled ES5 version of that code?如果他们可以直接运行 ES6,它如何确保执行 ES6 代码的行为绝对等同于执行该代码的转译 ES5 版本?

The answer to your question is simple: No, browser doesn't transpile your code.您的问题的答案很简单:不,浏览器不会转译您的代码。

There is no need because new specification try to stay backward compatible by adding new syntactic sugar, new functions and new apis, keeping the existing stuff as is.没有必要,因为新规范试图通过添加新的语法糖、新功能和新 API 来保持向后兼容,并保持现有内容不变。

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

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