If you are learning functional programming then you can’t go far without running into “identity function”.
An identity function is a very basic function that
- takes one argument
- returns the argument
This seems like the most useless function in the world. We never needed any function like this while building any application. Then what’s the big deal about this identity function.
In this blog we will see how this identity concept is used in the real world.
Again please note that in the following code
R stands for
Ramda and not
for programming language R.
Here is same code using Ramda.js.
Here we will use identity as the return value in the default case.
Get the unique items from the list.
Count occurrences of items in the list.
Begin value from zero all the way to n-1.
Filter truthy values.