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


In Chapter 2, you saw that there are five primitive data types (number, string, boolean, null, and undefined) and we also said that everything that is not a primitive piece of data is an object. Now you also know that:

  • Objects are like arrays but you specify the keys.

  • Objects contain properties.

  • Some of the properties can be functions (functions are data, var f = function(){};). Properties that are functions are also called methods.

  • Arrays are actually objects with predefined numeric properties and a length property.

  • Array objects have a number of useful methods (such as sort() or slice()).

  • Functions are also objects and they have properties (such as length and prototype) and methods (such as call() and apply()).

Regarding the five primitive data types, apart from undefined (which is essentially nothing) and null (which is also an object), the other three have corresponding constructor functions: Number(), String(), and Boolean(). Using these, you can create objects, called wrapper...