Monthly Archives: February 2011

Variable visibility in javascript

Every function has it’s own scope. A place where we can declare variables that are only available within the function it’s self. We’ve already seen how this can create private variables in a constructor. But there is much more to … Continue reading

Posted in Javascript | Tagged , | 1 Comment

Constructors vs factories

Often in Javascript, you only want one instance of an object. In classical OOP this is done with a singleton design pattern. In javascript we simply use the object literal (i.e. { property: ‘value’}). But when we need a multitude … Continue reading

Posted in Javascript | Tagged , | Leave a comment

Inheritance using the Caller extension pattern

The caller extension pattern is a design pattern I’ve discovered, which let’s you create constructors that can inherit from any other constructor. To do this we get to use some javascript magic: the call and apply methods. So let’s see … Continue reading

Posted in Javascript | Tagged , | Leave a comment

A critical look at javascript’s prototype

Javascript’s prototype is often compared to the inheritance model used by classical OOP languages. In these languages a sub class inherits properties and methods from a super class. In the sub class you can then add and override methods and … Continue reading

Posted in Javascript | Tagged | Leave a comment

The basics of javascript prototype

In the next couple of articles I’ll introduce a number of design patterns that I feel have the potential to be the staple food of any javascript application. But to really understand these, we need to first understand some of … Continue reading

Posted in Javascript | Tagged | Leave a comment

The case for RequireJS, part 2

In the part one of this article we’ve looked at the way RequireJS helps structure an application in javascript. But there is more to it then that. RequireJS is a pretty recent tool in a landscape dominated by big players … Continue reading

Posted in Javascript | Tagged , , , | Leave a comment