直接访问表
最后更新于:2022-04-02 04:16:15
[TOC]
## 一个月中的天数
```
If (moth = 1)Then
days = 31
Else If (month = 2) Then
days = 28
Else If (month = 3) Then
days = 31
...
```
使用表驱动
```
DIm DaysPerMonth() As Interger = {31,28,31,30,31,30,31,31,30,31,30,31}
days = daysPermonth(month -1)
```
## 星期几
bad
```
const day = new Date().getDay()
let day_zh;
if(day === 0){
day_zh = '星期日'
}else if(day === 1) {
day_zh = '星期一'
}
...
else{
day_zh = '星期六'
}
```
good
```
const week = ['星期日', '星期一',..., '星期六']
const day = new Date().getDay(
const day_zh = week[day]
```
';