A_J,
мысли вслух ...
class Data{
constructor(){
this.objects=[];
}
fillObjects(some_data){this.objects.push(...some_data.map(a => (a.self = this, a)))}
deleteObject(id){
this.objects.splice(id,1);
}
}
class Obj{
constructor(n){
this.n = n;
}
destructor(){
const id = this.self.objects.findIndex(a => a === this);
this.self.deleteObject(id)
}
}
const getObjectsFromOutside = arr => arr.map(n => new Obj(n))
window.data=new Data();
data.fillObjects(getObjectsFromOutside([6,9,0,5])); // тут пополняется массив data.objects экземплярами Obj
console.log(data.objects);
let elem = data.objects[2];
elem.destructor();
console.log(data.objects);