23.5Naming Conventions / No `self`

`this`への参照を保存しない

`this`への参照を保存しないでください。アロー関数または`Function#bind`を使用します。

かつては、コールバック関数内で外側の `this` を参照するために `const self = this;` や `const that = this;` のような回避策が必要でした。しかし、アロー関数は `this` をレキシカルに束縛するため、この問題は完全に解決されます。モダンなJavaScriptでは、この古いパターンを使う理由はなく、アロー関数を使う方がはるかにクリーンです。

❌ Bad
// bad
function foo() {
  const self = this;
  return function () {
    console.log(self);
  };
}
✅ Good
// good
function foo() {
  return () => {
    console.log(this);
  };
}