There is a way to pass a Date by value?
I use the follows method with a Date: "fechaEnvio" to calc the better option
- Code: Select all
function obtenerDif(fechaEnvio, calendex){
var dias = 0
calendex--
while(fechaEnvio.getDay() != calendex){
dias++
fechaEnvio.setDate(fechaEnvio.getDate() + 1)
}
return dias
}
but when the method finish the Date is changed because it was passed by reference not by value
i solved the problem creating a new date and seting the tieme to it
But i would like to know how to pass a data by value
thanks