js输出当前星期几--switch case

var taday = new Date();
var week = taday.getDay();
    switch(week){
        case 0:
            str = "星期日";
            break;
        case 1:
            str = "星期一";
            break;
        case 2:
            str = "星期二";
            break;
        case 3:
            str = "星期三"
            break;
        case 4:
            str = "星期四";
            break;
        case 5:
            str = "星期五";
            break;
        case 6:
            str = "星期六";
            break;
    }

document.write(str)

你可能感兴趣的:(JavaScript,case,switch,js输出当前星期几)