Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS箭头函数和function的区别 #18

Open
danLawrence opened this issue Jun 25, 2021 · 0 comments
Open

JS箭头函数和function的区别 #18

danLawrence opened this issue Jun 25, 2021 · 0 comments

Comments

@danLawrence
Copy link
Owner

JS箭头函数和function的区别:

  • 箭头函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象。

  • 箭头函数不可以当作构造函数,也就是说,不可以使用new命令,否则会抛出一个错误。

  • 箭头函数不可以使用arguments对象,该对象在函数体内不存在。如果要用,可以用Rest参数代替。

  • 不可以使用yield命令,因此箭头函数不能用作Generator函数。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant