【笔记】JS中的bind函数
前言
JS中的bind()函数学习笔记
改变函数的this指向
无形参列表
- 不会立即执行函数,只会改变函数的this指向
- 返回的是原函数的拷贝
1 | function 函数名() { |
应用
定时器传递this
1 | let btn = document.querySelector("button"); |
有形参列表
1 | function 函数名(参数, 参数) { |
JS中的bind()函数学习笔记
1 | function 函数名() { |
1 | let btn = document.querySelector("button"); |
1 | function 函数名(参数, 参数) { |