-
Notifications
You must be signed in to change notification settings - Fork 0
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
箭头函数和普通函数之间的区别 #15
Labels
Comments
总结
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
语法不同
普通函数
箭头函数
不绑定this
箭头函数在使用call、apply、bind时只能传参,无法绑定this,即第一个参数会忽略
箭头函数不绑定arguments
箭头函数不绑定Arguments对象,如果需要在箭头函数中使用类似于arguments的方法,可以选择使用剩余参数的方式
(...args)
箭头函数不能使用new操作符
箭头函数不能用作构造器,和
new
一起用会抛出错误箭头函数没有prototype属性
箭头函数不能用作生成器
yield
关键字通常不能在箭头函数中使用(除非是嵌套在允许使用的函数内)。因此,箭头函数不能用作生成器。The text was updated successfully, but these errors were encountered: