Home > Web Front-end > JS Tutorial > Node.js asynchronous non-blocking callback function

Node.js asynchronous non-blocking callback function

黄舟
Release: 2017-01-17 15:37:04
Original
1409 people have browsed it

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('程序执行完毕');
Copy after login

Analysis: execute the program first, then read the file

Node.js asynchronous non-blocking callback function

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)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template