Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

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.

like image 408
Tomáš Zato - Reinstate Monica Avatar asked Dec 16 '13 16:12

Tomáš Zato - Reinstate Monica


1 Answers

=> 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)
like image 55
Eric Avatar answered Sep 22 '22 06:09

Eric