I need to store data in an object and then add it to another object
let globalSamples = {} as any;
let sample = { } as ISamplesDetail [];
sample = [];
for (let i = 0 ; i<this.prelevementLingette.samplesDetail.length; i++)
{
sample [i].id= this.old.samplesDetail[i].id;
sample [i].reference=this.old.samplesDetail[i].reference;
}
globalSamples.push(sample);
I encountered the error message
'Cannot set property 'reference' of undefined'
What steps should I take to fix this issue?