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

add demo #14528

Closed
wants to merge 1 commit into from
Closed

add demo #14528

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ noop.$inject = [];
return (transformationFn || angular.identity)(value);
};
```
```js
var getResult = function (fn, val) {
return (fn || angular.identity)(val);
};
var result = getResult(function (n) { return n * 2; }, 3); // result = 6
var null_result = getResult(null, 3);// null_result = 3
var undefined_result = getResult(undefined, 3);// undefined _result = 3
```
* @param {*} value to be returned.
* @returns {*} the value passed in.
*/
Expand Down