描述:
JS——回调与递归
实现:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function fn1(fn) {
console.log("_______");
fn(fn3);
}
function fn2(fn) {
console.log("aaaa");
fn();
}
function fn3() {
console.log("bbb");
}
fn1(fn2);
/*
* 执行速度快
* 执行函数是唯一(出口一定)
*
*
* */
function fn4() {
console.log("cccc");
}
// setTimeout(fn4,1000);
var i=0;
var sum=0;
function fn5() {
sum+=i;
i++;
if(i>31430){
return;
}
fn5();
}
fn5();
console.log(sum);
</script>
</body>
</html>