webveuje/teaching/jwl/课件/js/yuju.html
2021-04-01 09:06:07 +08:00

63 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script>
// if 条件语句 if-elseif -else
var a = 3;
// if(a>10){
// console.log("比10大")
// }else if(a>5){
// console.log("比10小 比5大")
// }else{
// console.log("比5小")
// }
switch (a) {
case 1: console.log("a等于1");break
case 2: console.log("a等于2");break
default:console.log("error")
}
// case 1=> a==1
// 每个case执行的语句后面都要加上break,不然的话所有的case都会执行
// default 当判断的条件都不满足时case后面的语句都不执行就执行default 里面的语句
// console.log(res)
// 循环语句 for while
while(a<5){
// console.log(a)
a++
}
// while里面的语句 一定要写上++ 不然就是永动机
// for(var i=0;i<5;i++){
// // console.log(i)
// }
// for in
var arr=["a","b",'c','d'] //=>值
// [0,1,2,3] =》下标 索引
for(var m in arr){
console.log(m,arr[m])
}
var obj={name:"123",age:10}
for(var x in obj){
console.log(x,obj[x])
}
</script>
</head>
<body>
</body>
</html>