Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8337b9b

Browse files
dotkugkalpak
authored andcommitted
docs(identity): add example
Closes #14528
1 parent 85a53ea commit 8337b9b

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Angular.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,22 @@ noop.$inject = [];
466466
* functional style.
467467
*
468468
```js
469-
function transformer(transformationFn, value) {
470-
return (transformationFn || angular.identity)(value);
471-
};
469+
function transformer(transformationFn, value) {
470+
return (transformationFn || angular.identity)(value);
471+
};
472+
473+
// E.g.
474+
function getResult(fn, input) {
475+
return (fn || angular.identity)(input);
476+
};
477+
478+
getResult(function(n) { return n * 2; }, 21); // returns 42
479+
getResult(null, 21); // returns 21
480+
getResult(undefined, 21); // returns 21
472481
```
473-
* @param {*} value to be returned.
474-
* @returns {*} the value passed in.
482+
*
483+
* @param {*} value to be returned.
484+
* @returns {*} the value passed in.
475485
*/
476486
function identity($) {return $;}
477487
identity.$inject = [];

0 commit comments

Comments
 (0)