“`” 错误优先的回调函数用于传递错误和数据。第一个参数始终应该是一个错误对象, 用于检查程序是否发生了错误。其余的参数用于传递数据。例如:
<pre><code class=""language-jsx"" lang=""jsx"">fs.readFile(filePath, function(err, data) {
if (err) {
//handle the error
}
// use the data object
});
</code></pre>
解析:这个题目的主要作用在于检查被面试者对于Node中异步操作的一些基本知识的掌握。
<pre><code> "“`
Was this helpful?
0 /
0