Language concepts

Error-first callback

Try the free JavaScript compiler

A convention in some Node APIs where the first argument represents failure and the second carries a successful result. Invocation timing and the meaning of the arguments are part of the API contract.

Formal Syntax & Structure

javascript syntaxjavascript
callback(error, result)

Working Example

Example Snippetjavascript
function read(done) { queueMicrotask(() => done(null, 8)); }read((err, value) => console.log(err ? "error" : value));console.log("started");
JavaScript Reference