Within my Angular 4 application, I have an object named allAvailableProviders structured as such - with provider IDs 71 and 72, followed by timestamps in a 24-hour format.
71: {…}
1514678400: […]
0: 800
1: 1300
1515283200: […]
0: 800
1: 1300
1515888000: […]
0: 800
1: 1300
72: {…}
1514678400: […]
0: 800
1: 1300
1515283200: […]
0: 800
1: 1300
1515888000: […]
0: 800
1: 1300
I have created a function to extract this data into a new array:
1514678400: []
800: []
0: 71
1: 72
1300: []
0: 71
1: 73
The code to achieve this is as follows:
let allDates = [];
for(let pid in this.allAvailableProviders)
{
for(let slotDate in this.allAvailableProviders[pid]){
if(!Array.isArray(allDates[slotDate])){
allDates[slotDate] = new Array();
}
for(let spots in this.allAvailableProviders[pid][slotDate]){
if(!Array.isArray(allDates[slotDate][spots])){
allDates[slotDate][spots] = new Array();
}
allDates[slotDate][spots].push(pid);
}
}
}
console.log(allDates)
However, the output on the console log appears to be different than expected:
Array [ <10 empty slots>, … ]
[…]
[0…99999999]
[100000000…199999999]
[200000000…299999999]
[300000000…399999999]
[400000000…499999999]
[500000000…599999999]
[600000000…699999999]
[700000000…799999999]
I am encountering issues with generating the desired output using JavaScript and TypeScript, unlike when utilizing jQuery. Are there any suggestions on how to resolve this discrepancy?