Posts

Showing posts from July, 2016

Currying Nowadays - Inheritance - Javascript

//English Hi Guys! sorry I've been too busy at work. I will do my best to keep writing about how cool JS is and the things you can do ;) Now, as you could see on my previous post , currying has evolved due to Function.prototype.bind . The purpose of this post is to see another example that's practical: "Inheritance" using currying! Imagine this scenario: The world has countries, a country has people. people could either be female or male and each person has a name, in JS, you could write a function like the following: function person(country,sex, name){ return 'Hello my Name is ' + name + ', I am a ' + sex + ' and I am from ' + country; } It looks easy but It will be hard to read and to maintain: function person(country,sex, name){ return 'Hello my Name is ' + name + ', I am a ' + sex + ' and I am from ' + country; } var pedro = person( 'Mexico' , '