I've been struggling to find a solution to my question because most of the responses I come across are too advanced for my beginner level understanding of JavaScript.
Below is the code snippet I am working with:
function xyPoint(x, y){
this.x = x;
this.y = y;
this.debugMessage = function(){
document.getElementById("messageArea").innerHTML =
"xyPoint(x, y) constructor called";
};
}
My goal is to have the informative message display automatically when I create a new instance of xyPoint using the following line of code:
var myPoint = new xyPoint(10, 20);
Instead of having to manually call the debugMessage method like this:
var myPoint = new xyPoint(10, 20);
myPoint.debugMessage();
Any assistance on how to achieve this would be greatly appreciated. Thank you in advance.