It started like this: I was reading some JavaScript code, written – he says charitably – some years ago. Much simplified, it looked something like this, with all identifiers renamed to protect the guilty: […]
READ MOREThere’s a concept in functional programming called currying which gives you the ability to create one function from another, and have the created function call the original but with some arguments prefilled in. To be ultra-rigorous, we assume the original function has n arguments, and currying produces a chain of n functions each taking one argument to produce the same results as the original. We, however, will skip that rigorous definition since it’s too constricting for our discussion here. Instead we’ll talk about partial function application, but call it currying anyway. In essence: we want to call function A that takes lots of parameters, but since some/most of them are preset to some default values, we’d prefer having another function B that calls A filling in those presets to save time/effort. […]
READ MORE(For background, please check out parts 1, 2, and 3 before reading this post.) […]
READ MORENow that we’ve seen the simple module pattern as well as ways to augment it, we should take a look at one final piece of the puzzle. […]
READ MORELast time I talked about the simple module pattern. This is where you create a function that returns an object with behavior and state and that behavior and state is implemented (and made private) by using a closure. We showed this by using the module pattern to create a stopwatch object. […]
READ MOREIf you recall, JavaScript closures are an extremely powerful concept in the language. By using JavaScript’s rather peculiar scoping rules, closures are a way of creating private variables and functionality for an object. The module pattern builds upon this feature. […]
READ MOREAnother stop on the road to becoming a JavaScript developer when you know C#. Fire up Firebug in Firefox and follow along. […]
READ MOREAnother in the series in learning JavaScript from the viewpoint of a C# programmer, using Firebug as our test engine. […]
READ MOREContinuing to learn JavaScript from the viewpoint of a die-hard C# programmer, using Firebug as our test engine. […]
READ MOREContinuing my series about learning JavaScript when you're a C# programmer, using Firebug in Firebox as our testing ground. […]
READ MOREContinuing the series on JavaScript for C# developers, in this episode we look at closure. […]
READ MORE