<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>函数的递归调用</title>
</head>
<body>
<script>
// x的阶乘
function fn(x) {
if (x <= 1) {
return 1;
}
return x * arguments.callee(x - 1);
}
console.log("阶乘");
console.log(fn(5));
</script>
</body>
</html>
网友评论