-1

recently i found some operators in Javascript looks:

=>

.

I tried to look it up on Google, but cannot find any explanation. Is there someone who knows about this operator?

Derick Kolln
  • 633
  • 7
  • 17
  • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Arrow_functions – georg Jan 06 '17 at 12:13
  • [SO docs: JavaScript Arrow function](http://stackoverflow.com/documentation/javascript/5007/arrow-functions#t=201701061213278367458) – t.niese Jan 06 '17 at 12:13
  • Or simply go on the [MDN page for operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators) and search there. – Sebastian Simon Jan 06 '17 at 12:17
  • An example of use is in **Arrow functions** https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/ – Ala Eddine JEBALI Jan 06 '17 at 12:18

1 Answers1

1

That is called arrow function

You can read more here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions#Arrow_functions

var a = [
  "Hydrogen",
  "Helium",
  "Lithium",
  "Beryl­lium"
];

var a2 = a.map(function(s){ return s.length });

var a3 = a.map( s => s.length );
Lucas Katayama
  • 4,445
  • 27
  • 34
  • Thanks, for example in D3.js: `.attr("a", (d, i) => 12 + i * 3)` can be rewritten as `.attr("a", function (d, i) {return (12 + i * 3)}` ?? – Derick Kolln Jan 06 '17 at 13:43
  • Yes... but there a diference between 'this' scope when using arrow functions and the normal functions..be aware of that – Lucas Katayama Jan 06 '17 at 16:59