| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/TypeError | [Back] [Original] |
Get to know MDN better
Esta pgina foi traduzida do ingls pela comunidade. Saiba mais e junte-se comunidade MDN Web Docs.
This feature is well established and works across many devices and browser versions. Its been available across browsers since julho de 2015.
* Some parts of this feature may have varying levels of support.
O objeto TypeError representa um erro de quando um valor no do tipo esperado.
Instncias TypeError
new TypeError([message[, fileName[, lineNumber]]])
messageOpcional. Mensagem, descrio do erro
fileName Opcional. O nome do arquivo contendo o cdigo que causou a exceo
lineNumber Opcional. O nmero da linha do cdigo que causou a exeo
O TypeError ativado quando um operador ou argumento passado para uma funo incompativel com o tipo esperado por esse operador ou funo.
TypeErrorPermite a adio de propriedades para o objeto TypeError.
O TypeError global no contm mtodos por si s, no entanto, ele herda alguns mtodos atravs da cadeia prototype.
Instncias TypeErrorTypeErrortry {
null.f();
} catch (e) {
console.log(e instanceof TypeError); // true
console.log(e.message); // "null has no properties"
console.log(e.name); // "TypeError"
console.log(e.fileName); // "Scratchpad/1"
console.log(e.lineNumber); // 2
console.log(e.columnNumber); // 2
console.log(e.stack); // "@Scratchpad/2:2:3\n"
}
TypeErrortry {
throw new TypeError("Hello", "someFile.js", 10);
} catch (e) {
console.log(e instanceof TypeError); // true
console.log(e.message); // "Hello"
console.log(e.name); // "TypeError"
console.log(e.fileName); // "someFile.js"
console.log(e.lineNumber); // 10
console.log(e.columnNumber); // 0
console.log(e.stack); // "@Scratchpad/2:2:9\n"
}
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-native-error-types-used-in-this-standard-typeerror |
This page was last modified on 22 de mai. de 2026 by MDN contributors.
TypeErrorErrorObject/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()AggregateErrorEvalErrorInternalErrorRangeErrorReferenceErrorSyntaxErrorURIErrorYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |