2

What does that mean? How come I see it something used in the documents, but in practice through tutorials I don't ever see that?

example:

AppRegistry.registerComponent('MyApp', () => SimpleList);

Is it just a new way of saying this:

function() { return SimpleList }:

ie:

AppRegistry.registerComponent('MyApp', function() { return SimpleList });
hellomello
  • 7,510
  • 33
  • 121
  • 258
  • Yes, it's called a lambda function and is practically the same as the other way of doing it – Sami Kuhmonen Jun 15 '16 at 02:31
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Arrow_functions – Robby Cornelissen Jun 15 '16 at 02:32
  • Possible duplicate of [What's the meaning of "=>" (an arrow formed from equals & greater than) in JavaScript?](http://stackoverflow.com/questions/24900875/whats-the-meaning-of-an-arrow-formed-from-equals-greater-than-in-javas) – Bergi Jun 15 '16 at 02:51

2 Answers2

5

Yes, you are right.

() => SimpleList can be a replacement to function() { return SimpleList }

And no, you are not 100% right.
The this is same as the caller inside the arrow function, instead of a new this(new context) if you use function() {}

Check out this (http://es6-features.org/#Lexicalthis for more :)

David Guan
  • 3,702
  • 21
  • 29
0

In this case, the fat arrow and the function() { return SimpleList } will work the same. The difference is if your anonymous function wants to use refer to this, in which case the fat arrow will "do the right thing".

For more info, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

hugomg
  • 63,082
  • 19
  • 144
  • 230