我目前在网络浏览器中使用什么ECMAScript 6功能? [英] What ECMAScript 6 features can I currently use in web browsers?

查看:93
本文介绍了我目前在网络浏览器中使用什么ECMAScript 6功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ES6看起来像一个非常棒的语言!我对在线视频和演示文稿幻灯片中看到的所有内容印象深刻。



我很好奇我在现代浏览器中如何使用ES6。 ES6是否准备好了?此外,有没有办法使我的ES6代码向后兼容旧的ECMAscript运行时?

解决方案

是的,我同意! ES6看起来很令人兴奋。



最初,草稿的目的是在2013年底之前完成功能。该规范预计将在截止日期根据 Allen Wirfs-Brock的推文,该日期已被推回到6月



有关详细信息,请参阅

最佳猜测投票



如果一切顺利,我们将在2015年底之前在所有A级浏览器中看到。



使用ES6功能现在



许多功能都是已经在Firefox和Chrome上可用(Chrome上必须打开实验JavaScript ,以访问它)。这可能是Safari最长的时间。



显然,这将是几年之后,互联网上很大一部分人正在使用最新的-date浏览器如果您能够要求A级浏览器,则可以更快地进行转换。但是现在有一些工具可以帮助您开始进行转换:



已经为ES5兼容的浏览器开发了一个非常广泛的ES6垫片,可以在这里找到: https://github.com/paulmillr/es6-shim



它包含符号地图设置和大量新的数学 > String Array 函数。它正在与草稿一起开发,并且与最新的ES6草案非常接近。这是为了在ES6准备就绪之前做一个占位符,以便我可以开始编写ES6代码,当浏览器开始支持ES6时,代码将起作用。



不幸的是没有办法在句法变化中简单地填补。为此,您需要一个解释器,编译器,或只需等待浏览器。




  • Traceur 是一款ES6到ES5的透析器。

  • Continuum 是可在ES3浏览器中运行的ES6虚拟机。

  • Babel (以前称为6到5)是一个可以将ES6编码到ES5的转换器,将运行到任何地方。


ES6 looks like an incredibly awesome language! I'm really impressed with everything I've seen in videos and presentation slides online.

I'm curious as to how I can use ES6 in modern browsers. Is ES6 "production ready?" Furthermore, is there a way to make my ES6 code backwards compatible with older ECMAscript runtimes?

解决方案

Yes, I agree! ES6 is looking pretty exciting.

Originally, the draft was intended to be feature-complete by the end of 2013. And the spec is projected to be finalized by the end of 2014. This date, according to a tweet by Allen Wirfs-Brock, has been pushed back to June 2015.

For more details, see this blog post by Dr. Axel Rauschmayer.

Best Guess Projection

If all goes well we'll see it in all A-grade browsers by the end of 2015.

Using ES6 Features Now

Many of the features are already available on Firefox and Chrome (on Chrome you have to turn on experimental JavaScript in order to access it). It'll probably take Safari the longest.

Clearly, it'll be some years after that before a significant percentage of the people on the internet are using an up-to-date browser. If you're in the position to require A-grade browsers, you'll be able to make the transition more quickly. But there are some tools that can help start making the transition now:

There has been developed a pretty extensive ES6 shim for ES5 compliant browsers, available here: https://github.com/paulmillr/es6-shim

It includes shims for Symbols, Maps, Sets, and a host of new Math, String, and Array functions. It's being developed along with the drafts, and it's pretty close to up-to-date with the most recent ES6 draft. It's meant to be a placeholder until ES6 is ready so that I can start writing ES6 code now, code which will work when browsers start supporting ES6 natively.

Unfortunately there's no way to simply "shim" in the syntactic changes. For that you either need an interpreter, compiler, or just need to wait on the browsers.

  • Traceur is an ES6-to-ES5 transpiler.
  • Continuum is an ES6 virtual machine which can run in ES3 browsers.
  • Babel (formerly known as 6-to-5) is a transpiler that will compile your ES6 code to ES5 that will run everywhere.

这篇关于我目前在网络浏览器中使用什么ECMAScript 6功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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