Estoy tratando de ejecutar este código simple mientras aprendo a usar .prototype. Pongo p = new Particle(); esperando poder se p en la consola. Pero es indefinido. No puedo ver las propiedades de p como esperaba.
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(); }Lo probé y ya no veo el error:
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)