不理解 weekday[mydate.getDay()] 这一句,尤其是这个“【】” 请大神指教~ !
mydate.getDay()返回的是0,1,2,3,4,5,6的数字
0代表周天,返回的数字可以作为weekday[]这个数组的索引(下标)
比如今天星期五,weekday[mydate.getDay()] 就是weekday[5],取下标为5的数组的值 - 星期五。
参考代码
<script type="text/javascript"> var date = new Date(); var weekday = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]; var index = date.getDay(); ocument.write(weekday[index]); </script>
明白了,谢谢您!