DEV Community

Discussion on: Improve your JavaScript with functional programming

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).