Przejdź do treści

Error

TypeError

TypeError()
new TypeError()
TypeError(message)
new TypeError(message)
Parametry:
String message - komunikat błędu (domyślnie: "")
Wartość:
TypeError - nowa instancja obiektu błędu

Ta klasa dziedziczy po Error. Wskazuje, że typ wartości jest niezgodny z oczekiwanym.

Błąd TypeError może zostać rzucony w postaci wyjątku z funkcji:
Object.getPrototypeOf, Object.getOwnPropertyDescriptor, Object.getOwnPropertyNames, Object.create, Object.defineProperty, Object.defineProperties, Object.seal, Object.freeze, Object.preventExtensions, Object.isSealed, Object.isFrozen, Object.isExtensible, Object.keys,
Object.prototype.toLocaleString,
Function.prototype.toString, Function.prototype.apply, Function.prototype.call, Function.prototype.bind,
Array.prototype.toLocaleString, Array.prototype.every, Array.prototype.some, Array.prototype.forEach, Array.prototype.map, Array.prototype.filter, Array.prototype.reduce,
String.prototype.toString, String.prototype.valueOf,
Boolean.prototype.toString,
Number, new Number,
Number.prototype.toString, Number.prototype.valueOf,
Date.prototype.toString, Date.prototype.toDateString, Date.prototype.toTimeString, Date.prototype.toLocaleString, Date.prototype.toLocaleDateString, Date.prototype.toLocaleTimeString, Date.prototype.valueOf, Date.prototype.getTime, Date.prototype.getFullYear, Date.prototype.getUTCFullYear, Date.prototype.getMonth, Date.prototype.getUTCMonth, Date.prototype.getDate, Date.prototype.getUTCDate, Date.prototype.getDay, Date.prototype.getUTCDay, Date.prototype.getHours, Date.prototype.getUTCHours, Date.prototype.getMinutes, Date.prototype.getUTCMinutes, Date.prototype.getSeconds, Date.prototype.getUTCSeconds, Date.prototype.getMilliseconds, Date.prototype.getUTCMilliseconds, Date.prototype.getTimezoneOffset, Date.prototype.setTime, Date.prototype.setMilliseconds, Date.prototype.setUTCMilliseconds, Date.prototype.setSeconds, Date.prototype.setUTCSeconds, Date.prototype.setMinutes, Date.prototype.setUTCMinutes, Date.prototype.setHours, Date.prototype.setUTCHours, Date.prototype.setDate, Date.prototype.setUTCDate, Date.prototype.setMonth, Date.prototype.setUTCMonth, Date.prototype.setFullYear, Date.prototype.setUTCFullYear, Date.prototype.toUTCString, Date.prototype.toISOString, Date.prototype.toJSON,
new RegExp, RegExp,
JSON.stringify.

TypeError.prototype.name

TypeError.prototype.name
Wartość:
String - "TypeError"

Przykład:

TypeError.prototype.name;     // "TypeError"
TypeError("test").toString(); // "TypeError: test"
new TypeError("test") + "";   // "TypeError: test"

Komentarze

Zobacz więcej komentarzy