Re:What's a Closure?
by killerswan on Friday August 05, 2011 @10:56PM
(#2852806)
And it is important to remember that all functions in JavaScript can (and some say "should") be defined this way.
var c = 2;
var f = function (x) { return (2 * x); };
var g = function (h, x) { return h(x); };
Either you misunderstood, or the people using them misunderstood.
Lambdas are anonymous functions. In javascript terminology:
Closures are a way of hiding state (or at least data) in anonymous functions: Monads are a method of encapsulation, with goals similar to object orientation. OO is about hiding data inside objects, whereas monads are about hiding most of the outside world from your functions.