// js来获取当前星期几和之前的星期
var setWeek = function (num) { switch (num) { case 0: return '日' case 1: return '一' case 2: return '二' case 3: return '三' case 4: return '四' case 5: return '五' case 6: return '六' } } var arr = [] for (var i = 0; i < 7; i++) { a++ if (a > 6) a = 0 var b = setWeek(a) arr.push(b) } console.log(arr)
// ["六", "日", "一", "二", "三", "四", "五"]