first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
<!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>Function</title>
</head>
<body>
</body>
<script>
// 函数 Function
// 作用:实现代码 封装
// 定义
// function 方法名(参数1参数2.....) {}
// 返回方法的运行结果 return
// 调用
// 方法名()
// function Test(a,b) {
// return a + b
// }
// var a = Test(10, 100)
// var b = Test(1, 1)
// var c = Test(1, 2)
// var d = Test(1, 3)
// console.log(a,b,c,d);
// 匿名方法
var ddd = 1;
var a = function () {
console.log(ddd);
// 不加 var会做变量提升
var fff = 2222
console.log("fff1: ", fff);
console.log("我是function的另外一种写法");
}
a();
// 作用域
// 全局作用域
// 局部作用域
// 回调函数
// 把B方法作为参数传入到A方法中然后A调用B方法回传数据
// 解决 异步编程 返回值的问题
// 2 第二种方案,将异步转化为同步
// 同步
// 异步
function asyncFun(callback) {
var num = 1
setTimeout(function(){
num += 100;
callback(num)
}, 3000)
}
asyncFun( function(res) {
console.log(res);
} )
// function a1(callback) {
// var h = "100元钱"
// callback(h)
// }
// a1( function (res) {
// console.log(res)
// } )
// var hhhh = function () {
// console.log("111");
// }
// var u = hhhh
// u()
</script>
</html>