最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SyntaxError: invalid arrow-function arguments (parentheses around the arrow-function may help) - Stack Overflow

programmeradmin0浏览0评论

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)

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.

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. So, to make that clear, my browser is Mozilla Firefox 25.0.1.

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)

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.

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. So, to make that clear, my browser is Mozilla Firefox 25.0.1.

Share Improve this question edited Apr 20, 2015 at 9:03 hippietrail 17k21 gold badges109 silver badges179 bronze badges asked Dec 16, 2013 at 16:31 Tomáš ZatoTomáš Zato 53.4k63 gold badges310 silver badges825 bronze badges 9
  • You're using coffeescript, not javascript – Eric Commented Dec 16, 2013 at 16:32
  • 1 => should be >= ?? – PSL Commented Dec 16, 2013 at 16:32
  • 1 This question appears to be off-topic because it is about syntax error – PSL Commented Dec 16, 2013 at 16:33
  • 2 FYI, arrow functions are part of ES6 and seem to be supported in FF: developer.mozilla/en-US/docs/Web/JavaScript/Reference/…. – Felix Kling Commented Dec 16, 2013 at 16:34
  • @Eric No, I'm using regular javascript. – Tomáš Zato Commented Dec 16, 2013 at 16:34
 |  Show 4 more ments

1 Answer 1

Reset to default 6

=> should be >= (more than or equal)


An arrow-function is a coffeescript (and ES6!) feature - this:

f = x => this.y * x

Is equivalent to:

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论