I would just like to add an object of an class (Pixel) to an array.
export class Pixel {
constructor(x: number, y: number) {}
}
The class has the following attribute:
pixels: Pixel[] = [];
The following code looks logical for me, but does not push the actual objects to my array pixels.
this.pixels.push(new Pixel(x, y));
Only this works:
var p = {x:x, y:y};
this.pixels.push(p);
Could anybody explain me why the above statement does not work?