bind方法为例:
rest参数
Function.prototype.bind = function (context, ...args) {//args将接受多个参数形成一个数组
const fn = this
return function (...props) {
fn.call(context, ...args, ...props)//这里args又将数组进行了解构形成了多个参数
}
}
即时你不定义形参,js本身也支持传输0-n个参数,支持使用arguments类数组对象获取实参。但有时候我们需要对部分参数进行特别使用可以使用如上拓展运算符写法。