This is probably very silly but I have been reading the code too long and can't seem t find why is my variable not printing empty in the console if it hasn't reached the function where is actually pushing values into it. It works fine, I just want to understand why.
I've printed many console.log to track any line of code where I'm filling the variable (it's an array), I've also tried different things in other parts of the code but it is a const variable, so it can be assigned a different value from outside the function.
function ABC() {
console.log('FUNCTION BEGINS...');
const tempDates: Array<Moment> = [];
console.log(tempDates);
console.log('After creating the variable...');
console.log('Before log tempdates');
console.log(tempDates);
const start_date = this.date;
let dateToAdd = start_date;
tempDates.push(dateToAdd);
console.log(dateToAdd);
console.log(tempDates);
}
Maybe I'm wrong and over analyzing but I would expect the first time I print the const 'tempDates' to print an empty array. but actually outputs the array with 3 dates inside, which are actually filled if a condition is true, many lines of code after.
