0

I have started working on Javascript recently after a long break and saw a few instances where => operator is being used in many places. Is this something new and a shorthand of something? Where can I find documentation for it or can someone explain? I have googled it but couldn't find anything that could relate to =>

for Example,

browser.getCapabilities().then((c) => {
  console.log(c);
});

The one I could relate to is

browser.getCapabilities().then(function() {
  console.log(c);
});
nilesh
  • 14,131
  • 7
  • 65
  • 79
  • 2
    It is an [arrow function](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) – zerkms Jul 11 '16 at 04:45
  • Thanks @zerkms for the docs. I get it now – nilesh Jul 11 '16 at 04:48
  • Btw, "What's the meaning of => in Javascript" search on Google doesn't lead to any SO answers – nilesh Jul 11 '16 at 04:59
  • it's hard to search by non-alphanumeric operators in google. Even `"=>"` quoting it does not help much. For that very reason some languages implement specific character-friendly search over their docs, like https://www.haskell.org/hoogle/ (which is super cool btw) – zerkms Jul 11 '16 at 05:04

1 Answers1

1
(a,b) => a + b

is the same function as

function (a, b) {
    return a + b;
}
Adrian Brand
  • 20,384
  • 4
  • 39
  • 60