Help us understand the problem. What is going on with this article?

Arrow function を使いまくっても大丈夫なのか?

More than 3 years have passed since last update.

function=> の違いは、 this の bind と generator が使えるかどうかくらいという認識なので、タイプ量が減る分だけ基本的には => を使いたいと思っているのですが、パフォーマンス的な問題が気になったのでベンチ 1

試したバージョンは v4.1.1 から v5.0.0 までの5つ

Version Function Arrow function
v4.1.1 1,436,822,617 ops/sec ±0.73% 1,427,013,220 ops/sec ±0.83%
v4.2.0 1,444,479,245 ops/sec ±0.82% 1,435,019,562 ops/sec ±0.85%
v4.2.1 1,434,709,532 ops/sec ±0.87% 1,426,388,902 ops/sec ±1.03%
v4.2.2 1,444,670,434 ops/sec ±0.81% 1,430,149,639 ops/sec ±0.87%
v5.0.0 1,440,937,194 ops/sec ±0.74% 1,428,273,914 ops/sec ±1.02%

あんまり差はないので、自分が使うコードであれば気にしないでガンガン使ってしまいましょう!

  • => では this はレキシカルになるんだぞ!

  1. もちろん npm publish するときのことを考えると下位互換を考えれば使うべきではない、という問題はあるかと思いますが一旦それはそれでおいておきます。 

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした