0

Im trying to understand why changing the parameter in the function, changes the original value like here:

let originalDate = new Date()
console.log('originalDate before: ', originalDate)
changeDate(originalDate)
console.log('originalDate: after', originalDate)

function changeDate(date: Date) {
    date.setHours(0, 0, 0, 0)
}

typescript playground

What exactly is causing this?

0 Answers0