Here is a simple js code :
let day = 10;
let arrayMinutes = Array(day);
const d = new Date();
d.setHours(0);
d.setMinutes(1);
d.setSeconds(0);
arrayMinutes[0] = d;
console.log("arrayMinutes[0]", d, arrayMinutes[0], arrayMinutes);
const d2 = new Date();
d2.setHours(0);
d2.setMinutes(day);
d2.setSeconds(0);
arrayMinutes[day - 1] = d2;
console.log("arrayMinutes[day]", arrayMinutes[0], arrayMinutes[day - 1], arrayMinutes);
And the console logs :
Why arrayMinutes[0] evaluates to 0? According to me it should be equal to d.

dayin your first line of code?dayto10, I don't get 0 at all, it logs a Date as expected: jsfiddle.net/khrismuc/cs0mnkfqdayis10, the code doesn't do what you've said it does. Please update the snippet to accurately reflect what you're seeing.return arrayMinutes) at the end of the function. And the function (calledinitX) is used to initialize a var, which, I suspect, is modified after. So returning the array is like returning a pointer, and therefore if afterward the data pointed are modified, the console.log shows the modified data. My suspiscions are correct to javascript gurus ?