Basic HTML version of Foils prepared 8 Feb 98

Foil 81 User-defined Objects

From Overview of Basic JavaScript -- Web Scripting Language CPS616 Technologies of the Information Age -- Spring Semester 98. by Tom Scavo,Geoffrey C. Fox


Objects are defined with the function statement. The following Circle object, for example, has property r: function Circle( r ) { this.r = r || 1.0; }
The this keyword permits this function to be used as a constructor: var c = new Circle( 2.0 ); var area = Math.PI * c.r * c.r;



© 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 Sun Nov 29 1998