1

So I have saw tons of '=>' in some code I found online. Can anyone explain to me like I'm 5?

(I am looking for code, and I will post it here once I find it)..

Got it:

            var directive = () =>
        {
            return new MyDirective();
        };
Thomas Junk
  • 5,296
  • 2
  • 25
  • 39
uksz
  • 16,691
  • 26
  • 76
  • 142
  • 1
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions Google is your friend here. – CollinD Oct 31 '15 at 07:49
  • TypeScript arrow functions : https://basarat.gitbooks.io/typescript/content/docs/arrow-functions.html – basarat Nov 03 '15 at 22:42

2 Answers2

3

this is ECMASCRIPT 6 standard arrow function.

In this case directive is assigned a function with 0 arguments and one return statement

Details are documented here in MDN Docs

prasun
  • 6,324
  • 9
  • 33
  • 56
1

()=> is simply a lambda function, which (in this case) means nothing more than a shorthand notation for a function without a name taking 0 paramaters.

You could have written var directive=function(){return new MyDirective();};

Take a look at John Papas blog Post.

Thomas Junk
  • 5,296
  • 2
  • 25
  • 39