Web page display online time: `
var timeblc = document.getElementById("nowtime");
var weekdays = ["", "", "", "", "", "", ""];
function addZero(t){
if(t<10) return "0"+t;
return t;
}
function showTime(){
var time = new Date();
var t = time.getFullYear()+""+getMonthDay(time)+getWeekday(time)+getHMS(time);
timeblc.innerHTML = t;
setTimeout("showTime()",1000); //
}
function getMonthDay(time){
var m = addZero(time.getMonth()+1);
var d = addZero(time.getDate());
var str = m+""+d+"";
return str;
}
function getWeekday(time){
var str = weekdays[time.getDay()];
return str;
}
function getHMS(time){
var h = addZero(time.getHours());
var m = addZero(time.getMinutes());
var s = addZero(time.getSeconds());
var str = h+":"+m+":"+s;
return str;
}
showTime();`
At the code comment, the first parameter will cause a memory overflow if it does not add quotation marks:
after checking on the Internet, we can see that quotation marks will look for it globally, and if not, it will look for local variables. However, there is no relationship between the overflow and the way variables are queried.
ask for advice!