js中 call bind apply区别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35414779/article/details/84064385

call、apply、bind都是js中改变this的指向,但是使用起来不太一样。

call(this,agrument1,agrument2)

apply(this,[agrument1,agrument2])

bind(this)(agrument1,agrument2)

注意如果call和apply的第一个参数写的是null,那么this指向的是window对象

猜你喜欢

转载自blog.csdn.net/qq_35414779/article/details/84064385