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

Commit b67d145

Browse files
dotkugkalpak
authored andcommitted
docs(identity): add example
Closes #14528
1 parent 8dc1f8e commit b67d145

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
@@ -445,12 +445,22 @@ noop.$inject = [];
445445
* functional style.
446446
*
447447
```js
448-
function transformer(transformationFn, value) {
449-
return (transformationFn || angular.identity)(value);
450-
};
448+
function transformer(transformationFn, value) {
449+
return (transformationFn || angular.identity)(value);
450+
};
451+
452+
// E.g.
453+
function getResult(fn, input) {
454+
return (fn || angular.identity)(input);
455+
};
456+
457+
getResult(function(n) { return n * 2; }, 21); // returns 42
458+
getResult(null, 21); // returns 21
459+
getResult(undefined, 21); // returns 21
451460
```
452-
* @param {*} value to be returned.
453-
* @returns {*} the value passed in.
461+
*
462+
* @param {*} value to be returned.
463+
* @returns {*} the value passed in.
454464
*/
455465
function identity($) {return $;}
456466
identity.$inject = [];

0 commit comments

Comments
 (0)