Precautions when using arrow functions
There are several points to note when using arrow functions.
- The this object in the function body is the object when it is defined, not when it is used (cannot be used
bind
,apply
modified). - Cannot be used as a constructor, that is, you cannot use the new command, otherwise an error will be thrown.
- 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.
- The yield command cannot be used, so arrow functions cannot be used as generator functions .