Javascript examples for Object:Constructor
call a method from within a constructor
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w ww . j a v a 2 s. c o m*/ function my(x, y){ this.x = x; this.y = y; this.debugMessage = function(){ document.getElementById("messageArea").innerHTML = "my(x, y) constructor called"; }; } var myPoint = new my(10, 20).debugMessage(); } </script> </head> <body> <div id="messageArea"></div> </body> </html>