使用ES6 Arrow功能是否有性能提升? [英] Are there performance gains in using ES6 Arrow Functions?

查看:152
本文介绍了使用ES6 Arrow功能是否有性能提升?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ES6中的新箭头功能就像单线程功能,使代码更加干净简洁,并且还可以让调用者的范围保持在功能内,这样就不需要像 var _this = this; ,或使用 bind 功能等。

The new arrow functions in ES6, are like one-liner functions which make code more clean and concise, and also allow you to keep the scope of the caller inside the function, so that you don’t need to do things like var _this = this;, or use the bind function etc.

在简单的JavaScript函数中使用ES6箭头函数有什么显着的性能提升?

Are there any significant performance gains in using ES6 arrow functions over plain javascript functions?

推荐答案

请记住,这个问题不能有一个普遍的答案,因为所有这些都是依赖于实现的。所以现在或某些浏览器的答案可能是 X ,以后可能是其他浏览器。

Keep in mind there can’t be an universal answer to this question, as always with all of which is implementation dependant. So the answer may be X now or with some browsers, and may be Y in the future or with other browsers.

这些规定说,这里有一些数据: http:// www。 incaseofstairs.com/2015/06/es6-feature-performance/ 。对于现在和主要浏览器,答案就是,甚至可能会受到性能的惩罚(根据上述规定)。

These provisions said, here are some data: http://www.incaseofstairs.com/2015/06/es6-feature-performance/ . For now and with major browsers, the answer is rather No and there might even be performance penalties (under the above provisions).

这篇关于使用ES6 Arrow功能是否有性能提升?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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