简体   繁体   English

SyntaxError:无效的箭头函数参数(箭头函数周围的括号可能有帮助)

[英]SyntaxError: invalid arrow-function arguments (parentheses around the arrow-function may help)

Such code will generate an error: 这样的代码会生成错误:

if(hr>t1[0]||(hr==t1[0]&&min=>t1[1]) && hr<t2[0]||(hr==t2[0]&&min<t2[1]))

The error: 错误:

SyntaxError: invalid arrow-function arguments (parentheses around the arrow-function may help) SyntaxError:无效的箭头函数参数(箭头函数周围的括号可能有帮助)

What does it mean, how did it happen? 它是什么意思,它是怎么发生的? Google searches for this error are desperately useless. 谷歌搜索这个错误是绝望无用的。

Edit: 编辑:

Seems to be caused by using => instead of >= . 似乎是由使用=>而不是>= But I'm still curious why is the error formulated like this, and what the arrow function is supposed to be. 但我仍然很好奇为什么错误的表达是这样的,箭头函数应该是什么。

Edit 2. 编辑2。

First, I didn't realise that this could actually be browser specific issue. 首先,我没有意识到这实际上可能是浏览器特定的问题。 Also, I didn't realise that these days, people use JS in other places than browser context. 另外,我没有意识到,现在人们在浏览器上下文以外的地方使用JS。 So, to make that clear, my browser is Mozilla Firefox 25.0.1. 所以,为了说清楚,我的浏览器是Mozilla Firefox 25.0.1。

=> should be >= (more than or equal) =>应该>= (大于或等于)


An arrow-function is a coffeescript (and ES6 !) feature - this: 箭头功能是一个coffeescript(和ES6 !)功能 - 这个:

f = x => this.y * x

Is equivalent to: 相当于:

f = function(x) {
    return this.y * x;
}.bind(this)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM