Files
ClassContent/历届学生/front-end-team-11/每天上课/2023-05-03/function.html
2024-09-27 02:06:13 +08:00

81 lines
1.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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>
</head>
<body>
</body>
<script>
// 函数(Function) 事件 写特效(从易到难) 项目前ajaxhttp 写项目...
// 函数 方法
// 作用:封装代码的
// function test() {
// console.log("test");
// }
// 回调 callback
// 异步 编程 获取返回值
// 网络请求
// Promise
// 同步 编程
// let SmsCode = function (callback) {
// let a = 1
// setTimeout(function() {
// a = 100;
// callback(a)
// },3000)
// // arguments 用于参数比较多的情况
// // console.log("test: ", arguments);
// // return true
// }
// SmsCode(function(res) {
// console.log(res);
// });
// 全局作用域
// 局部作用域
// 变量提升
// let test = function () {
// c = 1
// }
// test()
// let test2 = function () {
// console.log("test: ", c);
// }
// test2()
// 闭包
// 函数内部函数访问外部变量的过程
// 作用:缓存数据
// 容易内存泄漏
// let test2 = function () {
// let result = 3;
// let test3 = function (num) {
// result *= num
// return result;
// }
// return test3;
// }
// let res = test2()
// console.log( res(10) );
// console.log( res(30) );
</script>
</html>