函数调用,分支,循环,语句示例。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
function func1(param) {
console.log("execute function 'func1'" + param);
}
let func2 = (param) => {
console.log("Execute function func2" + param);
}
func1("hello");
func2("world");
</script>
<script>
let i = 0;
let j = 1;
if (i > j) {
console.log("i>j");
} else if (i === j) {
console.log("i===j");
} else {
console.log("i<j");
}
</script>
<script>
let u = 0;
switch (u) {
case 0:
console.log("0");
break;
case 1:
console.log("1");
break;
default:
console.log("-");
}
</script>
<script>
let v = 10;
while (v > 0) {
v--;
console.log(v);
}
for (v = 0; v < 10; v++) {
console.log(v);
}
</script>
</body>
</html>
运行结果: