DEV Community

Improve your JavaScript with functional programming

Nitin Jadhav on July 31, 2019

If you want to write your JavaScript code in a better way, one of the most effective techniques is functional programming (FP). It's no difficult t...
Collapse
 
romstar profile image
Rami • Edited

For loops are faster than map, filter, and reduce. They always will be since they don't have the overhead of call backs. Correct your post at the beginning

"it's faster than the other version" needs to be removed

Collapse
 
nitinja profile image
Nitin Jadhav

You are correct, Thanks. I have updated the article to reflect the same and added a footnote for performance.

Collapse
 
greg profile image
greg

Why const square = power.bind(null, 2) over const square = num => power(2, num)?

Collapse
 
nitinja profile image
Nitin Jadhav

I believe they are doing the same thing. bind() offers a built-in solution for writing a wrapper function, but with the added advantage of passing context as the first argument (which I haven't used here).

Collapse
 
josephthecoder profile image
Joseph Stevens

Functional Programming every time, all the time baby. 💯💯💯

Collapse
 
theodesp profile image
Theofanis Despoudis

One note:

function calculateArea = (radius) => 3.14 * radious * radius;is not valid javascript

Collapse
 
nitinja profile image
Nitin Jadhav

Thanks, corrected!