This point of javascript arrow function

Precautions when using arrow functions

There are several points to note when using arrow functions.

  1. The this object in the function body is the object when it is defined, not when it is used (cannot be used bind, applymodified).
  2. Cannot be used as a constructor, that is, you cannot use the new command, otherwise an error will be thrown.
  3. The arguments object cannot be used, the object does not exist in the function body. If you want to use it, you can use the Rest parameter instead.
  4. The yield command cannot be used, so arrow functions cannot be used as generator functions .

The direction of this in JS-arrow function

Guess you like

Origin blog.csdn.net/SJ1551/article/details/109293034