So I have a db document that holds some string values in an array, I want to push just the array from every entry into an array in the application for usage later, But I can see the array fine on the fetch, and when I iterate it but my "Global array" is staying empty can someone explain why?
specialDates : Specialdates[] = [];
specialRange: any[] = [];
this.specialDates.forEach(ag => {
//ag,range -> I can see fine
this.specialRange.push(ag.range);
//this.specialrange -> Stays empty
});
Array looks something like the following:
1205,1206,1207,1208
What is wrong with this approach?
Reason for doing this is because the documents have 2 fields minimum: EG -> ID/Array
And I just need the array
1 Answer 1
this.specialRange = this.specialDates.map(ag => ag.range)
Sign up to request clarification or add additional context in comments.
Comments
lang-js
this.specialRange = [...this.specialDates]this.specialDatesinitialized? Is it async?