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

什么时候不使用箭头函数? 说出三个或更多的例子? #294

Open
Sogrey opened this issue Sep 16, 2020 · 0 comments
Open

什么时候不使用箭头函数? 说出三个或更多的例子? #294

Sogrey opened this issue Sep 16, 2020 · 0 comments
Labels
模块化&ES5、ES6 模块化&ES5、ES6

Comments

@Sogrey
Copy link
Owner

Sogrey commented Sep 16, 2020

不应该使用箭头函数一些情况:

  • 当想要函数被提升时(箭头函数是匿名的)
  • 要在函数中使用this/arguments时,由于箭头函数本身不具有this/arguments,因此它们取决于外部上下文
  • 使用命名函数(箭头函数是匿名的)
  • 使用函数作为构造函数时(箭头函数没有构造函数)
  • 当想在对象字面是以将函数作为属性添加并在其中使用对象时,因为咱们无法访问 this 即对象本身。
@Sogrey Sogrey added the 模块化&ES5、ES6 模块化&ES5、ES6 label Sep 16, 2020
@Sogrey Sogrey added this to javascript in Web面经题 Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
模块化&ES5、ES6 模块化&ES5、ES6
Projects
Web面经题
javascript
Development

No branches or pull requests

1 participant