CKTIS / JavaScript
Error names: Error.prototype.name
An error object's name property describes its category, such as Error or TypeError. You can override it, but changing the name does not change the object's type or prototype chain.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
error.name
error.name = "CustomError"The entry label Error.name refers here to an error instance's name: read it as error.name. The property is defined on Error.prototype with the initial value "Error". Types such as TypeError provide their own names on their prototypes. The literal expression Error.name, however, reads the constructor function's name — a different property.
name identifies the category, while message describes the particular problem. Error.prototype.toString() uses both properties; when both are nonempty strings, the result is "name: message".
Error.prototype.name is writable, non-enumerable, and configurable. Assigning error.name = "ValidationError" to an ordinary instance creates an own property. It does not create a new error type or change the prototype chain: the object still satisfies error instanceof Error. The name alone therefore does not prove an object's type.
Examples
const error = new Error("Invalid input");
console.log(error.name);
error.name = "ValidationError";
console.log(error.name);
console.log(error.message);
console.log(error.toString());
console.log(error instanceof Error);Result
Error ValidationError Invalid input ValidationError: Invalid input true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.