Create object and method - Javascript Object

Javascript examples for Object:Object Method

Description

Create object and method

Demo Code

ResultView the demo in separate window

<html>
   <head>
      <script type="text/javascript">
function hex(x,y,side,isLast,color)//constructor.
{
    this.x = x;/*from w ww  .  jav  a2  s.  c om*/
    this.y = y;
    this.side = side;
    this.isLast = isLast;
    this.color = color;
    function multiply()
    {
        return this.x * this.y;
    }
    this.multiply = multiply;
}
var hexagon = new hex(22,22,20,0,1);
document.write(hexagon.multiply)

      </script> 
   </head>
   <body> 
      <!--Content here-->  
   </body>
</html>

Related Tutorials