According to the documentation
A function that returns its first argument. This function is useful when writing code in the functional style.
I
Example from the AngularJS source code:
function transformer(transformationFn, value) {
return (transformationFn || angular.identity)(value);
};
Explanation:
In case transformationFn
is provided as first parameter, it will be called with value
as it's own parameter. Otherwise identity
function will be called with the same value.
As ng source code mentions:
This function is useful when writing code in the functional style.
What this means is that in functional programming there are no globals, so you always have to pass/inject in everything you need.