I would like to create array or object of objects while calling constructor of class? I mean, everytime I'm calling class constructor it adds new object to array or object.
f.e.
let blocks = {};
class Block(){
constructor(X,Y,width,height){
this.X = X;
this.Y = Y;
...
and now I would like to add this created object to "blocks"
something like: blocks.push(and this object here)
}
}
How can I implement something like this? Or should it be another function?