recently, when I was learning nodejs, I saw that many functions are followed by a callback function. For example, I will give an inappropriate example and illustrate my doubts
for example, if there is such a code, I will rewrite it:
readFile("abc",(err,files) => {
if(err) throw err
else {
console.log(files) // readFilefalse,
}
})
for example, this function exposes the annotation function above the api implementation, then I am very good at how the odd source code will be defined. I also tried to write
myself. function readFile(path,callback) {
let flag = false
if(path) {
flag = true // flagtrueerrfalse
}
.... //
}
ask the great god to help solve the confusion, or it may be that my JS is not very solid. No, no, no. It"s a little messy, thank you