DEV Community

Discussion on: Closures in JavaScript

Collapse
 
baijanaththaru profile image
baijanathTharu

Closures are used in event handlers, callback functions and for protecting data which shouldn't be accessible in global scope.

Collapse
 
bias profile image
Tobias Nickel

the last example.is currying, I thing today peoplebwould write that more as

const addition = (num1) => (num3) => (num3) => num1 + num2 + num3;

I think the ramdalib and reduz take heavy use of this sytax.

I am glad that closures don't play such a big role today anymore, now that we have asyc/await.