Basic HTML version of Foils prepared 23 June 1997

Foil 28 User-defined Objects - II

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo


Object properties are accessed in natural o-o fashion:
var actualSelected = worldMenu.menuSelection;
familyMenu.color = 'red';
Curiously, in Netscape 2 you can also use array-like notation:
  • familyMenu[0] is same as familyMenu.no
  • familyMenu[1] is same as familyMenu.name etc.
We will return to this when we discuss arrays
One associates methods with user-defined objects, but with a syntax that appears very limiting since object methods have identical arguments to constructor function
General syntax is:
ObjectName.methodName = functionName;
where ObjectName is an existing object and functionName is an existing function Ñ it can be used to set event handlers with no arguments!



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998