在 JavaScript 中,我可以像下面这样将参数绑定到函数中:
当调用时,我们会得到以下输出...
能否在 .bind() 函数中跳过参数以实现以下输出?
function foo(arg1, arg2) { console.log(arguments); }
foo = foo.bind(this, 'bar');
当调用时,我们会得到以下输出...
foo('baz');
> { '0': 'bar', '1': 'baz' }
能否在 .bind() 函数中跳过参数以实现以下输出?
function foo(arg1, arg2, arg3, arg4) { console.log(arguments); }
foo = foo.bind(this, 'bar', null, 'qux');
foo('baz', 'lel');
> { '0': 'bar', '1': 'baz', '2': 'lel', '3': 'qux' }