gpt4 book ai didi

javascript - .bind 函数与 CoffeeScript

转载 作者:行者123 更新时间:2023-11-30 07:42:02 26 4
gpt4 key购买 nike

<分区>

当我尝试转换以下代码片段时......

result.pause = function() {        
cachedValue = this();
isPaused(true);
}.bind(result);

使用 http://js2coffee.org/它返回

result.pause = ->
cachedValue = this()
isPaused true
.bind(result)

但是,当您尝试编译该代码时,该代码不正确,您会返回 Error Unexpected '.'

在这种使用 CoffeeScript 的情况下,使用 .bind 函数的正确方法是什么?

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