Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[node] 5.什么是 error-first callback ? #375

Open
qiilee opened this issue Oct 8, 2019 · 0 comments
Open

[node] 5.什么是 error-first callback ? #375

qiilee opened this issue Oct 8, 2019 · 0 comments
Labels

Comments

@qiilee
Copy link
Member

qiilee commented Oct 8, 2019

答案:error-first callback 用来传递错误和数据。第一个参数永远是一个错误对象(error-object),回调函数必须检查它。余下的参数用不过来传递数据。

解析:

fs.readFile(filePath, function(err, data) {
  if (err) {
    //处理出现错误的情况
  }
  //处理数据
});

考察面试者对于 Node 异步操作基本知识的见解

@qiilee qiilee added the Node label Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant