Java Reference
In-Depth Information
Chapter
12
Object-oriented Programming in
JavaScript
Object-oriented programming (OOP for short) is a style of programming that involves
separating the code into objects that have properties and methods. Sound familiar?
JavaScript obviously supports objects, as we saw in Chapter 5 , so it also supports an object-
oriented style of programming. In this chapter, we'll look at what object-oriented program-
ming is and how to implement it in JavaScript.
In this chapter, we'll cover the following topics:
• an introduction to OOP
• constructor functions
• prototypes
• public and private methods
• inheritance
• creating objects from objects
• adding methods to built-in objects
• mixins
• chaining functions
• this and that
• borrowing methods from prototypes
• our project―create questions in an OOP way
Search WWH ::




Custom Search