Identity is probably the easiest one. It will be useful later on when a function is required as an argument but not given.
_.identity = function(val) {
return val;
}
This simply returns whatever value it is given.
If this confuses you, then these exercises are probably going to be way over your head. Just sayin..
Here's an example:
var test = _.identity("hello");
console.log(test);
The console will display = hello
No comments:
Post a Comment