Favorites

JavaScript Error.prototype.name Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Error.prototype.name
JavaScript Error Instance propertyThis property is supported by all modern browsers.
Updated 28th November 2026

The name property of an Error gives its type, such as Error, TypeError or a custom name.

Description

The name property identifies the type of error. Built-in errors have names such as "TypeError" and "RangeError". When creating a custom error class, set this.name so the type appears in logs. To check types, instanceof is more reliable than comparing names.

Custom error classes can set name as a class field, as shown above, or in the constructor after calling super(). Converting an error to a string, as when logging it, gives "name: message", so a meaningful name makes logs easier to scan.

Some web APIs throw DOMException objects, whose name identifies the problem, such as "AbortError" for aborted requests or "NotAllowedError" for blocked permissions; checking err.name is the standard way to handle those.

Syntax

error.name

Value

A string: the type of error, such as "TypeError".

Example

try { undefinedFunction(); } catch (e) { console.log(e.name); }
class NotFoundError extends Error { name = 'NotFoundError'; }
console.log(new NotFoundError('Missing').name);

Browser Support

The following information will show you the current browser support for the Error.prototype.name property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee