please dont rip this site

Language Java Script Definitive Examples 7.3.TXT

//  This example is from the book _JavaScript: The Definitive Guide_.    
// Written by David Flanagan.  Copyright (c) 1996 O'Reilly & Associates.
// This example is provided WITHOUT WARRANTY either expressed or implied.
// You may study, use, modify, and distribute it for any purpose.        

// First, define some functions that will be used as methods
function Rectangle_area() { return this.width * this.height; }
function Rectangle_perimeter() { return 2*this.width + 2*this.height; }
function Rectangle_set_size(w,h) { this.width =index.html w; this.height = h; }
function Rectangle_enlarge() { this.width *= 2; this.height *= 2; }
function Rectangle_shrink() { this.width /= 2; this.height /= 2; }

// Then define a constructor method for our Rectangle objects.
// The constructor initializes properties, and also assigns methods.
function Rectangle(w, h) 
{
    // initialize object properties
    this.width = w;
    this.height = h;

    // define methods for the object
    this.area = Rectangle_area;
    this.perimeter = Rectangle_perimeter;
    this.set_size = Rectangle_set_size;
    this.enlarge = Rectangle_enlarge;
    this.shrink = Rectangle_shrink;
}

// Now, when we create a rectangle, we can immediately invoke methods on it:
r = new Rectangle(2,2);
a = r.area();
r.enlarge();
p = r.perimeter();


file: /Techref/language/java/script/definitive/examples/7.3.txt, 1KB, , updated: 1997/4/4 11:59, local time: 2024/5/29 04:47,
TOP NEW HELP FIND: 
3.23.103.111:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.massmind.org/techref/language/java/script/definitive/examples/7.3.txt"> language java script definitive examples 7</A>

Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to www.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .