Syntax coffeescript抛出错误(“ExecJS::RuntimeError:语法错误:意外,在函数中

Syntax coffeescript抛出错误(“ExecJS::RuntimeError:语法错误:意外,在函数中,syntax,coffeescript,Syntax,Coffeescript,我在coffeescript中编写了此函数: doCalculate = (old, new) -> difference = roundNumber (old - new, 5) 但编译时会产生错误: throw Error("ExecJS::RuntimeError: SyntaxError: unexpected , 如果我删除,5部分,就不会再出现错误 我想不出逗号有什么问题 在同一文件中,函数roundNumber的定义如下: roundNumber = (rnum,

我在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

谢谢:)

do
roundNumber(entry-exit,5)
无论我是否在rlength中使用默认值,都会发生错误。可能的重复项