每个函数都有,除了箭头函数
如何传 arguments
调用 fn 即可传 arguments
fn (1,2,3) 那么 arguments 就是[1,2,3] 伪数组
如何传 this
用 call 传 this
如果call传的不是对象,JS会帮你自动封装成对象
fn.call(xxx, 1, 2, 3) 传 this 和 arguments
call
需要手动把person 传到函数里,作为this
不用this时,需要找个东西占位,可以是undefined,null等等
this 的两种使用方法
隐式传递
显示传递
使用 bind 绑定this
使用.bind 可以让 this 不被改变
.bind 还可以绑定其他参数
箭头函数
立即执行函数(用的少)
在匿名函数前面加个运算符即可
!、() 、~、+、- 都可以
推荐使用 !
JS中唯一用到分号的地方