(For background, please check out parts 1, 2, and 3 before reading this post.) […]
READ MOREWay back in March 2009, I wrote a quick post about the JavaScript arguments quasi-array, about how the interpreter sets it up on every call to every function to hold the arguments passed to that function. […]
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 MOREI can’t believe that I haven’t posted an article on how to call functions in JavaScript and what this
gets set to for each of the various invocation patterns. It’s one of those things that catches people out periodically, so it’s well worth discussing at length. […]
I’ll admit this one is really wacky, so sit yourself down and read through this slowly. It’s OK if you need to take a break for a breather and to clear your mind. I had to the first time I came across this little, er, hack. […]
READ MORELike 99% of all jQuery users, I write the code I want executed when the document is ready like this: […]
READ MOREI was answering a JavaScript question on stackoverflow when a common usage scenario presented itself, one with a subtle gotcha that could catch you out. Perfect for a quick blog post. (Note: you could also view this post as an adjunct to my popular JavaScript callback posts (I, II, III).) […]
READ MOREWhen I first started learning and writing JavaScript, the recommendation I came across again and again was that the equality operator, ==
, or “double-equals” was the devil incarnate. You should always use the identity operator, ===
, or “triple-equals” because then you won’t have to battle weird type coercion bugs (and remember it’s not necessarily the time you write the original code that you’ll get tripped up, it’s the time you maintain it for the nth time). […]