0

I was testing some javascript functions in the Chrome console and found that I can write functions like C# expressions.

var testFunction = (v1, v2) => v1 + v2;
var result = testFunction(2, 3);
// result is 5

I have search about it on google, but I didn't find anything about this specific syntax.

Is this something new or just a resource from the Chrome console? Does browsers commonly support this?

Thiago Romam
  • 439
  • 4
  • 14

2 Answers2

2

Some information you can read here https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions

  • This is a link only answer, at least answer the question here ("This is an arrow function...") and link to the docs for more info. – Jamiec May 31 '17 at 15:17
  • Thanks for the reference link. The main problem is that I didn't know what this function are. The reference link has all awnsers I need. – Thiago Romam Jun 01 '17 at 14:55
2

Those are called Arrow functions and are supported in all browsers except IE and Opera Mini, as you can see in this Can I use link.

rickvdbosch
  • 14,105
  • 2
  • 40
  • 53
  • Thanks for the help. I know what it is about now. I looked the link you mention and search about the compatibility. I also made some tests and find that the current version of Opera Mini (and Opera Browser) does support it. I will look to use it in my javascript library for web systems, since Chrome support is fully supported. – Thiago Romam Jun 01 '17 at 14:58