Code 102: Class 6 Reading Notes
JavaScript - Jon Duckett
Chapter 3: 3: “Object Literals” (pp.100-105)
Textbook notes/mostly direct quotes
-
“IN AN OBJECT: VARIABLES BECOME KNOWN AS PROPERTIES If a variable is part of an object, it is called a property.”
-
IN AN OBJECT: FUNCTIONS BECOME KNOWN AS METHODS If a function is part of an object, it is called a method. Methods represent tasks that are associated with the object.
-
Like variables and named functions, properties and methods have a name and a va lue. In an object, that name is called a key.
*An object cannot have two keys with the same name. This is because keys are used to access their corresponding values. The value of a property can be a st ring, number, Boolean, array, or even another object. The va lue of a method is always a function.
-
Web browsers implement objects that represent both the browser window and the document loaded into the browser window.
-
JavaScript also has several built-in objects such as String, Number, Math, and Date. Their properties and methods offer functionality that help you write scripts. Arrays and objects can be used to create complex data sets (and both can contain the other).
Chapter 5: “Document Object Model” (pp.183-242)
The Document Object Model (DOM) specifies how browsers should create a model of an HTML page and how JavaScript can access and update the contents of a web page while it is in the browser window.
You will hear people call the DOM an Application Programming Interface (API). User interfaces let humans interact with programs; APls let programs (and scripts) talk to each other. The DOM states what your script can “ask the browser about the current page, and how to tell the browser to update what is being shown to the user.
DOM trees have four types of nodes: document nodes, element nodes, attribute nodes, and text nodes.
You can select element nodes by their id or cl ass attributes, by tag name, or using CSS selector syntax
In older browsers, implementation of the DOM is inconsistent (and is a popular reason for using jQuery).
- Most of the content is better viewed in book, as image heavy, and better explained with visual charts and diargrams as book listed.