When an error occurs, JavaScript creates an Error object. It has two main properties: name (the error type) and message (what went wrong).
const err = new Error("Something failed");
console.log(err.name); // "Error"
console.log(err.message); // "Something failed"
You can create your own errors to signal problems in your code.