loading...

re: The beauty of Functional Programming VIEW POST

FULL DISCUSSION
 

Another important thing that functional programming encourage is function composition. Even the most simple function can be useful if you combine it with something else.

This is one example that I really like. Say that you have this function.

function identity(arg) {
  return arg;
}

It may seen useless but if you have map function that works like Array.map but for "plain" objects, you could implement a shallow_copy function like this.

function shallow_copy(obj){
  return map(identity, obj);
}
 

Yes, this is a nice example, I agree. And i will explain more about this, in the next posts

code of conduct - report abuse