The angular.identity
function returns the first argument passed to it.
angular.identity(argument)
This function is useful for functional programming, you can provide this function as a default in case an expected function was not passed.
Examples:
angular.identity(42) // 42
var mutate = function(fn, num) {
return angular.isFunction(fn) ? fn(num) : angular.identity(num)
}
mutate(function(value) {return value-7}, 42) // 35
mutate(null, 42) // 42
mutate("mount. rushmore", 42) // 42