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

Cute_Ninja
  • 4,742
  • 4
  • 39
  • 63
  • "(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". – geocodezip Aug 27 '14 at 18:29
  • Do you know what is the right syntax then to be able to use fat arrow function? – Cute_Ninja Aug 27 '14 at 18:29
  • 2
    I think "fat arrow" functions work only in [FireFox](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/arrow_functions) at the moment. – Teemu Aug 27 '14 at 18:54

1 Answers1

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

Community
  • 1
  • 1
user3566643
  • 535
  • 1
  • 4
  • 8