call / apply / bind

2018-09-23  本文已影响2人  _William_Zhang

因为参数太多时,用 .call 一个一个传参 要累死的....,不如用 apply ,整体的 apply 进去!


image.png 用bind

传给 bind 的 this,会作为 onClick.call 的第一个参数。即:bind(this) 等价于 onClick.call(this)。 嗯,可以这么理解。

(mdn之 bind 的文档)https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind

上一篇 下一篇

猜你喜欢

热点阅读