HTML and CSS Reference
sharing of behavior between them. We started by gaining a thorough understanding
to constructors and used them in conjunction with their prototype property
to implement an emulation of classical inheritance. Pseudo-classical inheritance
inheritance mechanism, but can lead to complex solutions that are computationally
Dispensing the constructors, we moved on to prototype-based inheritance and
jects with other objects. By implementing a simple Object.create function, we
avoided some of the confusion introduced by constructors and were able to see
clearer how the prototype chain helps us extend the behavior of our objects.
Functional inheritance showed us how closures can be used to store state and
achieve truly private members and methods.
combining all of the previously discussed patterns. Mixins are a great match for
Which technique to use? The answer will vary depending on whom you ask.
There is no one right answer, because it depends on your situation. As we've seen,
there are trade-offs when choosing between a pseudo-classical approach and a func-
tional approach that will be affected by whether object creation, method invocation,
memory usage, or security is the most crucial aspect of your application. Through-
out this topic we'll see how to use a few of the techniques presented in this chapter
in real life examples.