I am going through a for loop, adding a time onto the current date, and adding the new date into an array. However, when I output the array once the loop is completed, it is filled with 50 instances of the same date. Logging these dates from within the loop however shows them being incremented correctly. Is this something to do with the data being updated after it has already been pushed into the array?
var dates = new Array();
var currentDate = new Date();
for (var i =0; i < 50;i++){
currentDate.setDate(currentDate.getDate()+2);
console.log(currentDate);
dates.push(currentDate);
}
console.log(dates);