1.书写位置
2.变量
补充(1)JS的注释
(2)JS的输出
效果图
3.数据类型
4.数据类型转换
5.运算符
6.条件分支语句if
7.案例-平年还是闰年
<script>
var year=2078
if(year%4===0&&year%100!==0||year%400==0)
{
console.log(year+'是闰年')
}else{
console.log(year+'不是闰年')
}
</script>
8.条件分支语句switch
9.案例-一年中的第几天
<script>
var year=2022
var month=8
var date=8
var total=0
switch(month){
case 12:total+=30;
case 11:total+=31;
case 10:total+=30;
case 9:total+=31;
case 8:total+=31;
case 7:total+=30;
case 6:total+=31;
case 5:total+=30;
case 4:total+=31;
case 3:total+=28;
case 2:total+=31;
}
</script>
10.循环结构语句
(1)while
(2)dowhile
(3)for