Book Image

Object-Oriented JavaScript

By : Stoyan Stefanov, Stoyan STEFANOV
Book Image

Object-Oriented JavaScript

By: Stoyan Stefanov, Stoyan STEFANOV

Overview of this book

Table of Contents (18 chapters)
Object-Oriented JavaScript
About the Author
About the Reviewers
Built-in Functions
Regular Expressions


Let's summarize the most important topics you have learned in this chapter.

  • All functions have a property called prototype. Initially it contains an empty object.

  • You can add properties and methods to the prototype object. You can even replace it completely with an object of your choice.

  • When you create objects using a function as a constructor (with new), the objects will have a secret link pointing to their prototype, and can access the prototype's properties as their own.

  • Own properties take precedence over prototype's properties with the same name.

  • Use the hasOwnProperty() method to differentiate between own properties and prototype properties.

  • There is a prototype chain: if your object foo doesn't have a property bar, when you do, JavaScript will look for a bar property of the prototype. If none is found, it will keep searching in the prototype's prototype, then the prototype of the prototype's prototype and keep going all the way up to the highest-level parent Object....