TypeError

  • Tags
  • Files

 

Summary

Represents an error when a value is not of the expected type.

Syntax

new TypeError([message[, fileName[, lineNumber]]])

Parameters

message
Human-readable description of the error
fileName
Non-standard
The name of the file containing the code that caused the exception
lineNumber
Non-standard
The line number of the code that caused the exception

Description

A TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or function.

Properties

For properties available on TypeError instances, see Properties of TypeError instances.

prototype
Allows the addition of properties to an TypeError object.

Properties inherited from Function.prototype
caller, constructor, length, name

Methods

For methods available on TypeError instances, see Methods of TypeError instances.

The global TypeError contains no methods of its own, however, it does inherit some methods through the prototype chain.

TypeError instances

All TypeError instances inherit from TypeError.prototype. You can use the prototype to add properties or methods to all instances.

Properties

constructor
Specifies the function that created an instance's prototype.
name
Error name.
Note: Although ECMA-262 specifies that TypeErrorTypeError should provide its own message property, in SpiderMonkey, it inherits Error.prototype.message.

Methods

constructor
Specifies the function that created an instance's prototype.
name
Error name.
Note: Although ECMA-262 specifies that TypeErrorTypeError should provide its own message property, in SpiderMonkey, it inherits Error.prototype.message.

See also

Contributors to this page: Potappo, Sevenspade
Last updated by: Potappo,