递归出题
This commit is contained in:
55
teaching/jwl/课件/js/bibao.html
Normal file
55
teaching/jwl/课件/js/bibao.html
Normal file
@@ -0,0 +1,55 @@
|
||||
<!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>
|
||||
function f1() {
|
||||
var n = 999;
|
||||
// console.log(n)
|
||||
function f11() {
|
||||
console.log(n)
|
||||
}
|
||||
// f11()
|
||||
return f11
|
||||
}
|
||||
|
||||
var f2 = f1(); // =>f11
|
||||
f2()
|
||||
// 函数在没有return 语句或者是return 后面为空的时候, 函数的返回值等于undefined
|
||||
// 如果return 后面不为空的话 那么函数的返回值 即等于 return后面的东西
|
||||
|
||||
// console.log(f2)
|
||||
|
||||
|
||||
|
||||
var name = "The Window";
|
||||
|
||||
var object = {
|
||||
name: "My Object",
|
||||
|
||||
getNameFunc: function () {
|
||||
var that = this;
|
||||
return function () {
|
||||
return that.name;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
alert(object.getNameFunc()());
|
||||
|
||||
var func=object.getNameFunc()
|
||||
func()
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user