How do JavaScript closures work?
Closures are hard to explain because they are used to make some behaviour work that everybody intuitively expects to work anyway. I find the best way to explain them (and the way that I learned what they do) is to imagine the situation without them:const makePlus = function(x) {return function(y) { return x y; }; }const plus5 = makePlus(5); console.log(plus5(3));