JS回调

Time: 2024-07-21 Sunday 14:49:01
Author: Jackasher

JS回调

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function sum(a,b,cb){
const nowTime = Date.now()

setTimeout(() => {
cb(a + b)
},3000)
}

console.log("1111111111");

const sumResult = sum(123,456,(result) => {
console.log(result);
})

console.log("2222222222");

本质JS回调是把函数作为参数,在异步内容中调用函数

回调地狱就是依赖回调的结果不断在内部嵌套

回调函数本身就是结果本身


JS回调
http://example.com/2024/07/21/JS回调/
作者
Jack Asher
发布于
2024年7月21日
许可协议