Favorites

JavaScript TypeError Object

☕
Enjoying this site?

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

Buy us a coffee
TypeError
JavaScript Errors · ConstructorThis object is supported by all modern browsers.
Updated 28th November 2026

A TypeError is thrown when a value isn't the type an operation expects, such as calling something that isn't a function or reading a property of undefined.

Description

A TypeError is the most common error in JavaScript. It is thrown when an operation is used on a value of the wrong type: calling a value that isn't a function, reading a property of undefined or null, assigning to a constant, or changing a frozen object in strict mode.

Messages such as "Cannot read properties of undefined" usually mean a variable or property you expected doesn't exist yet. The optional chaining operator ?. and checks with typeof help avoid them. You can also throw a TypeError yourself when a function receives an argument of the wrong type.

In strict mode, which applies to modules and classes, many silent failures become TypeErrors, such as writing to a read-only property or adding a property to a frozen object. Mixing BigInt and Number values in arithmetic, calling a class without new, and using new with an arrow function also throw one. Error messages differ between browsers, so check the type rather than the message text.

Creating

new TypeError(message)

Example

try {
  const user = undefined;
  user.name;
} catch (err) {
  console.log(err instanceof TypeError, err.message);
}

try {
  null();
} catch (err) {
  console.log(err.name);
}

Browser Support

The following information will show you the current browser support for the TypeError object. Hover over a browser icon to see the version that first introduced support for this object.

This object 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