Instance method : Member Function : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » Member Function »

 

Instance method

















<HTML>
<HEAD>
<TITLE>Instance method demo</TITLE>
</HEAD>
   <BODY>
   <H1>
   <SCRIPT>
   function Rectangle(height, width){
      this.height =  height;
      this.width = width;
   }
   function calc_Area () {
      return this.height * this.width;
   }

   function to_String() {
      return this.height + " by " +this.width;
   }
   Rectangle.prototype.calcArea = calc_Area;
   Rectangle.prototype.toString = to_String;

   var theRectangle = new Rectangle (242);
   document.write(theRectangle);
   </SCRIPT>
   </H1>
   </BODY>
</HTML>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» Member Function