这样的代码会产生一个错误:
if(hr>t1[0]||(hr==t1[0]&&min=>t1[1]) && hr<t2[0]||(hr==t2[0]&&min<t2[1]))
错误:
SyntaxError: 无效的arrow-function 参数(arrow-function 周围的括号可能有帮助)
这是什么意思,它是如何发生的? Google 搜索此错误毫无用处。
编辑:
似乎是使用=>=而不是=引起的。但我仍然很好奇为什么错误是这样表述的,以及箭头函数应该是什么。
编辑 2.
首先,我没有意识到这实际上可能是特定于浏览器的问题。另外,我没有意识到现在人们在浏览器上下文之外的其他地方使用 JS。所以,为了说明这一点,我的浏览器是 Mozilla Firefox 25.0.1。
最佳答案
=> 应为 >=(大于或等于)
箭头函数是 coffeescript(和 ES6 !)的特征 - 这个:
f = x => this.y * x
相当于:
f = function(x) {
return this.y * x;
}.bind(this)
关于javascript - 语法错误 : invalid arrow-function arguments (parentheses around the arrow-function may help),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20615839/