Say I have code like this:
function Foo(func)
{
var a = new SomeClass(func(5));
}
var b = new Foo(x=>x);
What does the x => x mean in the parameter? x is not defined anywhere else.
Say I have code like this:
function Foo(func)
{
var a = new SomeClass(func(5));
}
var b = new Foo(x=>x);
What does the x => x mean in the parameter? x is not defined anywhere else.
It is the arrow notation,
x=>x
implies function which takes one parameter and returns back the same parameter.
It is the same as:-
function test(x) {
return x;
}
var b = new Foo(test);
As @Hozefa said, the function accepts the parameter x
and returns it back.
Basically:
const func = x => x
means:
const func = function (x) {
return x
}
It's an ES6 Syntax which you learn more here: http://es6-features.org/