-1

I don't understand how this => works. I googled "javascript =>" but found no good answer.

var isTriangle = (a,b,c) => Math.max(a,b,c)<(a+b+c)/2

  • Also, read [the operator reference on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators) and [What does this symbol mean in JavaScript?](http://stackoverflow.com/q/9549780/4642212). – Sebastian Simon Feb 04 '17 at 15:51

1 Answers1

0

This is the new ECMAScript 6 fat arrow syntax for defining functions. Your example:

(a,b,c) => Math.max(a,b,c)<(a+b+c)/2

is approximately equal to:

function(a, b, c) { return Math.max(a,b,c)<(a+b+c)/2; }

...but a lot shorter.

This site has more examples.

Wander Nauta
  • 14,707
  • 1
  • 39
  • 59