Callback function (asynchronous non-blocking)
main.js file
[code]// 引入文件模块 var fs = require('fs'); // 读取test.txt文件 fs.readFile('test.txt', function (err, data) { if (err) return console.log(err); console.log(data.toString()); }); console.log('程序执行完毕');
Analysis: execute the program first, then read the file
The above is the content of Node.js asynchronous non-blocking callback function. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!