difference = roundNumber (old - new, 5) 但是编译时会-6ren">
gpt4 book ai didi

syntax - coffeescript throw Error("ExecJS::RuntimeError: SyntaxError: unexpected , 在函数中

转载 作者:行者123 更新时间:2023-12-02 00:08:12 25 4
gpt4 key购买 nike

我用 coffeescript 写了这个函数:

doCalculate = (old, new) ->
difference = roundNumber (old - new, 5)

但是编译时会产生错误:

throw Error("ExecJS::RuntimeError: SyntaxError: unexpected ,

如果我删除 , 5 部分,我就不会再收到任何错误。

我不知道逗号有什么问题。

函数 roundNumber 在同一个文件中定义如下:

 roundNumber = (rnum, rlength = 6) ->
pow = Math.pow( 10, rlength )
newnumber = Math.round ( rnum * pow ) / pow
parseFloat(newnumber)

最佳答案

啊啊啊我想通了。 coffeescript 要求函数名称和左括号之间没有空格。

它甚至可以在没有括号的情况下工作。

但如果函数名称和 (.

这有效:

difference = roundNumber old - new, 5

谢谢 :)

关于syntax - coffeescript throw Error("ExecJS::RuntimeError: SyntaxError: unexpected , 在函数中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17041713/

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