var mydate=new Date();
var year=mydate.getFullYear();
var month=mydate.getMonth()+1;
var date=mydate.getDate();
var day=myweek[mydate.getDay()]
var myweek=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
document.write(year+"年"+month+"月"+date+"日"+day);
myweek这个数组应该是放在day之前合理些,还有,每句代码之后加上”;”
为什么myweek要放在day之前的原因是因为代码是依次执行的,先执行“var day=myweek[mydate.getDay()];”这句,这时候myweek的初始化还没有做,所以day拿不到myweek的值