On Classical, Swiss and Parasitic Inheritances
Durable Objects
What does KISS stand for?
JavaScript Widgets Without 'this'
Understanding JavaScript OOP
Parasitic inheritance is really The Decorator Pattern in disguise
Performance Boosting Tips
from Java Classes to JavaScript Prototypes
the difference between a 'closure' and a 'lambda'?
Closures Demystified
 
JavaScript's OOP inheritance system
wonders of closures (a.k.a lambdas or just function in JavaScript)


JavaScript's OOP inheritance system
Peter Michaux and Douglas Crockford have cleary explained different OOP patterns in Javascript.
JavaScript OOP>http://michaux.ca/articles/javascript-oop-encapsulation-durable-objects-parasitic-inheritance-and-the-decorator-pattern
JavaScript Widgets Without "this" >http://peter.michaux.ca/articles/javascript-widgets-without-this

Classical Inheritance does not exist in Javascript.
It is only clumsy emulated in Javascript, in order to look similar to Java. It is misleading, obsolete and NOT necessary programming style.

Javascript closure explained using events > http://jondavidjohn.com/javascript-closure-explained-using-events/

-------------------------------------
Various types of OOP patterns:
-------------------------------------
GOOD - Classical Inheritance.. Java language
BETTER - Prototypal inheritance.. Self language
THE BEST - Closures (a.k.a lambdas).. Scheme language * (a Lisp dialect)

JavaScript's prototypal inheritance system is interesting and more flexible than classical inheritance schemes; however, even the prototypal system is difficult going most of the time. I imagine all JavaScript programmers have struggled to make the prototypal system work for them.

The prize waiting for me was, of seems to be usual, rooted in the wonders of closures (a.k.a lambdas or just function in JavaScript)

Where are all the books on design patterns for closure-based languages?

.........................
Creating Closures
.........................
A closure is created when an inner function is made accessible from outside of the function that created it. This typically occurs when an outer function returns an inner function. When this happens, the inner function maintains a reference to the environment in which it was created. This means that it remembers all of the variables (and their values) that were in scope at the time. The following example shows how a closure is created and used.

function add(value1) {
return function doAdd(value2) {
return value1 + value2;
};
}
var increment = add(1);
var foo = increment(2);
// foo equals 3

...............................
Emulating Private Data
...............................
Many object-oriented languages support the concept of private member data. However, JavaScript is not a pure object-oriented language and does not support private data. But, it is possible to emulate private data using closures. Recall that a closure contains a reference to the environment in which it was originally created―which is now out of scope. Since the variables in the referencing environment are only accessible from the closure function, they are essentially private data.
The following example shows a constructor for a simple Person class. When each Person is created, it is given a name via the “name” argument. Internally, the Person stores its name in the “_name” variable. Following good object-oriented programming practices, the method getName() is also provided for retrieving the name.

function Person(name) {
this._name = name;
this.getName = function() {
return this._name;
};
}

There is still one major problem with the Person class. Because JavaScript does not support private data, there is nothing stopping somebody else from coming along and changing the name. For example, the following code creates a Person named Colin, and then changes its name to Tom.

var person = new Person("Colin");
person._name = "Tom";
// person.getName() now returns "Tom"



Personally, I wouldn’t like it if just anyone could come along and legally change my name. In order to stop this from happening, a closure can be used to make the “_name” variable private. The Person constructor has been rewritten below using a closure. Note that “_name” is now a local variable of the Person constructor instead of an object property. A closure is formed because the outer function, Person() exposes an inner function by creating the public getName() method.
function Person(name) {
var _name = name;
this.getName = function() {
return _name;
};
}

Now, when getName() is called, it is guaranteed to return the value that was originally passed to the constructor. It is still possible for someone to add a new “_name” property to the object, but the internal workings of the object will not be affected as long as they refer to the variable bound by the closure. The following code shows that the ”_name” variable is, indeed, private.

var person = new Person("Colin");
person._name = "Tom";
// person._name is "Tom" but person.getName() returns "Colin"


...............................
What is a Closure?
...............................
A closure is an inner function that has access to the outer (enclosing) function’s variables—scope chain. The closure has three scope chains: it has access to its own scope (variables defined between its curly brackets), it has access to the outer function’s variables, and it has access to the global variables.
A closure is the local variables for a function - kept alive after the function has returned.
Closures are functions that refer to independent (free) variables. In other words, the function defined in the closure 'remembers' the environment in which it was created in.
Closures are an extension of the concept of scope. With closures, functions have access to variables that were available in the scope where the function was created.
A closure is a stack-frame which is not deallocated when the function returns. (As if a 'stack-frame' were malloc'ed instead of being on the stack!)
Languages such as Java provide the ability to declare methods private, meaning that they can only be called by other methods in the same class. JavaScript does not provide a native way of doing this, but it is possible to emulate private methods using closures.
A "closure" is an expression (typically a function) that can have free variables together with an environment that binds those variables (that "closes" the expression).
Closures are an abstraction mechanism that allow you to separate concerns very cleanly.