ObjectsUnit 9 |
|
Constructor |
|
Sample 9-1 shows using a function as a constructor to build an object. |
|
Method |
|
sample 9-2 shows adding a method. |
|
Extend an Object |
|
sample 9-3 extend shows extending an Object by adding a property and a method. |
|
Extend a
|
|
sample 9-4 class shows extending a |
|
Object Constructor |
|
sample 9-5 the Object constructor function is provided by JavaScript. Note that the function does not have a name, however it is a method, and the property that refers to the method does have a name. |
|
Object literal |
|
Sample 9-6 object literal shows use of a literal object. It also shows object notation and associative array notation. |
|
Lab 3 |
|
In lab 3 you will build one more page. |
|
Put your web page on the Internet |
|
Put your page on the Internet. |
|
Test your page |
|
Validate your page before trying to get the JavaScript to work. Then make sure the JavaScript works. |
|
Complete lab 3 |
|
You have done all the work for lab 3. |
|
Reading assignment |
|
Reading assignments are in the text book, Java Script, A Beginner's Guide, Second Edition, by John Pollock; McGraw Hill / Osborne, ISBN 0-07-222790-7 Read Module 8.
I had the misfortune to teach out of a book, that was written by a community college teacher.
They did not understand commercial programming, so they suggested approaches that worked in a
school lab, but were bad in a large commercial project. Read section 8.1 - In "What Is an Object", first paragraph, the book suggests you visual something general when thinking of an object. I suggest you think of something specific. An object in JavaScript represents a single specific thing. The book is a little fuzzy on this.
Read section 8.2 - In the section on "Constructor Functions", the book indicates
The part of the script with the constructor function, instance creations, and variable assignments is placed in the HEAD section so that they load first The document.write() commands are used in the BODY section so that they display in the browser
In the section on "Object Initializers", the keyword var is omitted before the variable names:
Look at section 8.3 - This section discusses the object that represents the browser. Note that the browser is always called Navigator. Navigator was the leading browser when this object was built. The Navigator object is used for all browsers today. This stuff is very interesting, and often useful. We will mostly omit the Navigator; we cannot do everything in one course. We will look at other built-in objects, some of which we will use. Alternate reading assignments are in the text book, Java Script Concepts & Techniques Programming Interactive Web Sites, by Tina Spain McDuffie; Franklin, Beedle & Associates, ISBN 1-887902-45-7 Read Chapter 16. |
|
Lecture notes |
|
Do NOT read the lecture notes before hearing the lecture. If you do, you will find the lecture very boring. Read the lecture notes if you do not attend the lecture, or if you wish to review the material. |
|