Javascript call和apply的区别
- 非严格模式:
- fn.call() // this ->window
- fn.call(null) // this ->window
- fn.call(undefined) // this ->window
- 严格模式:
- fn.call() // this ->undefined
- fn.call(null) // this ->null
- fn.call(undefined) // this ->undefined
- apply和call方法功能一样
- 区别:
- call传参,一个个传
- apply,传参是数组