In EcmaScript 2015 (ES6) the expression (x) => x * 2
means to create an anonymous function with one parameter x
that will return x * 2
. For example:
(x) => x * 2
// is equivalent to:
function(x) { return x * 2; }
A modified example from [documentation by Mozilla Developer Network][1] page demonstrates how they are useful:
var a = [
"Hydrogen",