<script type="text/javascript">
var mydate=new Date();//定义日期对象
var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];//定义数组对象,给每个数组项赋值
var mynum=mydate.getDay();//返回值存储在变量mynum中 document.write(mydate.getDay());//输出getDay()获取值
document.write("今天是:"+ weekday[mynum]);//输出星期几</script>
为什么最后一行突然把mynum作为weekday里的一个项呢?前面没有写他们之间的联系啊,谁可以帮我解释一下这个问题
getDay()的返回值是(0,1,2,3,4,5,6)对应的("星期日","星期一","星期二","星期三","星期四","星期五","星期六")
所以mynum是weekday数组中的下标,然后输出weekday数组中mynum这个下标中的值