Home  >  Article  >  Web Front-end  >  What is the difference between arrow functions and ordinary functions in js

What is the difference between arrow functions and ordinary functions in js

王林
王林Original
2020-04-28 14:48:4411148browse

What is the difference between arrow functions and ordinary functions in js

The difference between arrow functions and ordinary functions in js is as follows:

1. Different styles, arrow function is =>, ordinary function is function;

2. The arrow function cannot be used as a constructor, so the new keyword cannot be used;

3. The arrow function does not bind arguments, so you can consider using the remaining parameters instead;

4. Arrow The function will capture the this value of its context as its own this value, which is determined when it is defined;

5, call, apply, and bind will not affect the direction of this;

6. The arrow function has no prototype attribute;

7. The arrow function cannot be used as a generator function, and the yield keyword cannot be used;

Recommended tutorial: js introductory tutorial

The above is the detailed content of What is the difference between arrow functions and ordinary functions in js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn