I want to set object with data and then pushed 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 got this error 'Cannot set property 'reference' of undefined'
How can I resolve the problem ?
if (!sample[i]) continue;in order to jump to the next iteration if sample[i] is null or undefined.