I have a query regarding the code snippet provided below:
var d = new Date();
var weekday = ["su", "mo", "tu", "we", "th", "fr", "sa"];
var deliver = weekday[d.getDay()];
if(condition){
if(d.getDay() == 1){
d.setHours(d.getHours() + 24); // adds a day
}
if(d.getUTCMonth() == 0 && d.getUTCDate() == 1){
// do something
} else {
// version 1 or version 2
}
}
//version 1: var deliver = weekday[d.getDay()];
// document.getElementById("leverdatum").innerHTML = deliver;
//version 2: document.getElementById("leverdatum").innerHTML = deliver;;
I'm puzzled as to why the output is "tu" when using version 1, and "mo" when using version 2. Can you explain this behavior?