Object Oriented JavaScript Notes

Array methods

Some array methods that you might find helpful are split, join, and splice. You can find them on Mozzilla's web development site using these links:
split
join
splice

Functions as Data

Pages 356-362 of Chapter 8 of Fundamentals of Web Development explain how functions are data (objects) 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 368-370 of Ch. 8) is also useful when working with Ajax.

JSON

Object literals (see page 353 of Fundamentals of Web Development) 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. We used JSON to describe sample game states for Assignment 1 and will use it again when we work with Ajax in Assignments 5 and 6.

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. Fundamentals of Web Development has a short introduction to JSON on pages 889-891. We will look at JSON (and XML) later in the term.

No classes in JavaScript

There are no class definitions in JavaScript prior to ES2015. 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 8 of Fundamentals of Web Development. ES2015 defined a class keyword and syntax for defining classes but we won't be using class definitions in CS2550.