0

http://robcee.net/2013/fat-arrow-functions-in-javascript/ - checked my syntax here

I am trying to use it in my code but it gives this error

Uncaught SyntaxError: Unexpected token > 

at this line

google.maps.event.addListener(this.map, "rightclick", (event) => {

in this code

google.maps.event.addListener(this.map, "rightclick", (event) => {
     this.showContextMenu(event);
});

If i replace the fat arrow function by this

var self = this;
google.maps.event.addListener(this.map, "rightclick", self.showContextMenu);

It works fine. but, the I do not have access to the variables that i want to have. hence, to fix the scoping issue I used fat arrow function. Does anyone know why it aint working in my code. To me the syntax looks right for fat arrow function

3
  • "(event) => {" isn't valid syntax. The last argument of the addListener function needs to be a function "pointer" or something that returns a function "pointer". Commented Aug 27, 2014 at 18:29
  • Do you know what is the right syntax then to be able to use fat arrow function? Commented Aug 27, 2014 at 18:29
  • 2
    I think "fat arrow" functions work only in FireFox at the moment. Commented Aug 27, 2014 at 18:54

1 Answer 1

1

Why isn't this JavaScript syntax supported in Google Chrome?

Fat arrow function is not implemented in Chrome yet.

However, Firefox does support it. - see screenshot below

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.