I am trying to run this simple code while learning how to use .prototype.
I put p = new Particle(); expecting to be able to se p in the console.
But it's undefined. I can't see the properties of p as I expected.
function Particle(){
this.x = 100
this.y = 99
this.show = function(){
point(this.x, this.y);
}
}
var p;
function setup() {
createCanvas(600, 300);
p = new Particle();
}
I tried it and don't see error anymore:
function Particle(){
this.x = 100
this.y = 99
this.show = function(){
point(this.x, this.y);
}
}
var p;
function setup() {
p = new Particle();
}
setup();
console.log(p)