Object Oriented JavaScript Notes

Functions as Data

Pages 244-253 of Modern JavaScript explains how functions are data and can be assigned to variables, passed as parameters, and so on. This concept will be important to understand when we look at Ajax later in the term. The concept of closures (pages 541-546 of Ch. 14) is also useful when working with Ajax.


Object literals (see pages of Modern JavaScript in JavaScript are the basis for JavaScript Object Notation (JSON). JSON is sometimes used as an alternative to XML because a JSON object literal is often shorter and simpler than an equivalent XML document.

You can learn more about JSON at http://json.org The web site has links to a number of JSON libraries for various programming languages. You can read about using JSON in JavaScript in pages 444-447 of Modern JavaScript We will look at JSON (and XML) later in the term.

No classes in JavaScript

There are no class definitions in JavaScript (prior to ECMAScript 6). Instead, you can use constructors and prototype objects to do things that might be done with classes in Java, C++, or C#. You can read about constructors and prototypes in Chapter 14 of Modern JavaScript. (More recent versions of JavaScript have a class keyword and syntax for defining classes but we won't be using class definitions.)