Object Oriented Programming

The features from this chapters are a bit higher than newbie level.

But still crucial to good programming.

Exceptions

  1. Check-first error handling
  2. The try..catch construct
  3. The full form of try..catch..finally
  4. The throw statement
  5. Exception analysis and rethrow
  6. Summary

Understanding exception is important to object-oriented programming in general and JavaScript in particular.

Exceptions is a special, very powerful way to deal with errors.

Prototypal inheritance

  1. Inheritance, the __proto__
  2. Object.create, Object.getPrototypeOf
  3. The prototype
  4. Crossbrowser Object.create(proto)
  5. hasOwnProperty
  6. Looping with/without inherited properties
  7. Summary

In most languages, there are classes and objects. Classes inherit from other classes.

In JavaScript, the inheritance is prototype-based. That means that there are no classes. Instead, an object inherits from another object Smile

Early and Late Binding

  1. Use cases/mistakes
  2. Binding with var self = this
  3. Early binding
    1. Function.prototype.bind
    2. Comparison
  4. Late binding
    1. Problems of early binding
    2. The late binding in action
  5. Summary

JavaScript sets value of the execution context "this" at call time. Being a bless of flexibility, this is also a curse of wrong context.

There are numerous situations when a function must keep the context no matter how it runs, and reference same object.

The "constructor" property

  1. Example
  2. The origins of constructor
  3. Keeping constructor up to date
  4. Summary

An object has a build-in property named constructor. It is meant to reference the function which made the object, but it fails to do it sometimes.

Tutorial

Donate

Donate to this project