gpt4 book ai didi

javascript - 直接在函数签名上绑定(bind)、调用和应用调用

转载 作者:行者123 更新时间:2023-11-30 16:38:41 25 4
gpt4 key购买 nike

<分区>

我已经用 JS 编程大约一年了,我发誓有办法做到这一点:

function a(){

}.bind(this);

function a(){

}.apply(this,null);

我能做到:

(function a(){
console.log('b');
}).apply(null);

a(); //but this will throw an error

有没有办法做我想做的事?我只想在不丢失作用域的情况下调用应用、调用或绑定(bind)函数。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com