<!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>
<button id="but">点击按钮</button>
</body>
<script>
//函数的嵌套调用
// 如:a函数调用b函数,b函数又调用c函数,c函数调用d函数
but.onclick = function test() { //类似入口文件,也是最后的出口文件,其他文件都是中间调用的
console.log("111");
f1()
console.log("222");
}
function f1() {
console.log("333");
f2()
console.log("444");
}
function f2() {
console.log("555");
f3()
console.log("666");
}
function f3() {
console.log("777");
console.log("888");
}
//最终显示:111,333,555,777,888,666,444,222;
</script>
</html>
运行结果