of object-oriented programming: encapsulation, polymorphism, and inheritance. We have
looked at using constructor functions to create multiple instances of objects, as well as using
objects to create more objects. We have also seen how to use mixins to add modular func-
tionality to objects.
The key points of the chapter are summarized here:
• Object-oriented programming (OOP) is a way of programming that uses objects as
• The main concepts of OOP are encapsulation, polymorphism, and inheritance.
• Constructor functions can be used to create instances of objects.
• Inside a constructor function, the keyword this refers to the object returned by the
• All instances of a constructor function inherit all the properties and methods of its
• The prototype object is live, so new properties and methods can be added to existing
• The prototype chain is used to find an available method. If an object lacks a method,
function's prototype until it finds the method or reaches the Object constructor
• Private properties and methods can be created by defining variables using var and
defining a function inside a constructor function. These can be made public using
getter and setter functions.
• Monkey-patching is the process of adding methods to built-in objects by augment-
ing their prototype objects. This should be done with caution as it can cause unex-
pected behavior in the way built-in objects work.
Search WWH ::