LoginSignup
1

More than 5 years have passed since last update.

Arrow Function の「束縛」の歴史。束縛してるのしてないの?

Last updated at Posted at 2017-10-19

諸事情によりほとんど追いかけていなかったJavaScript周りの情報を追いかける必要がでてきて
Arrow Function の説明を書いてあるサイトをあちこち見たのですが、

  • this を束縛する
  • this を束縛しない

二通りの説明が存在して困惑しました。

歴史

MDNの変更歴史の影響にみえます。

リビジョン 1012725

アロー関数式(またはファットアロー関数)はfunction式に比べより短い構文を持ち、 this の値をレキシカルに束縛します。アロー関数は常に匿名関数です。

束縛する

this の値をレキシカルに束縛します

リビジョン 1050326

アロー関数式 は、function 式 と比べてより短い構文を持ち、this の値を語彙的に束縛します (ただし、自身の this や arguments, super, new.target は束縛しません)。アロー関数は、常に 匿名関数 です。

束縛するけど束縛しない

this の値を語彙的に束縛します (ただし、自身の this や arguments, super, new.target は束縛しません)

リビジョン 1265125

アロー関数式 は、function 式 より短い構文で、this, arguments, super, new.target を束縛しません。アロー関数は、メソッドでない関数に最適で、コンストラクタとして使うことはできません。

束縛しない

this, arguments, super, new.target を束縛しません

英語版

An arrow function expression has a shorter syntax than a function expression and does not have its own this, arguments, super, or new.target. These function expressions are best suited for non-method functions, and they cannot be used as constructors.

肝心の部分は

does not have its own this, arguments, super, or new.target

ですね。

ガイドページ

アロー関数式 (ファットアロー関数としても知られる)は関数式と比較してより短い構文を持ち、this の値をレキシカルに束縛します。アロー関数は常に無名関数です。

束縛する

this の値をレキシカルに束縛します

まとめ

特にこの領域に詳しいわけではないので自身の意見はありません。

外部資料

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1