aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/javascript/reference/global_objects/referenceerror
diff options
context:
space:
mode:
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/referenceerror')
-rw-r--r--files/pt-br/web/javascript/reference/global_objects/referenceerror/index.html171
1 files changed, 171 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/referenceerror/index.html b/files/pt-br/web/javascript/reference/global_objects/referenceerror/index.html
new file mode 100644
index 0000000000..5a00314c2c
--- /dev/null
+++ b/files/pt-br/web/javascript/reference/global_objects/referenceerror/index.html
@@ -0,0 +1,171 @@
+---
+title: ReferenceError
+slug: Web/JavaScript/Reference/Global_Objects/ReferenceError
+translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError
+---
+<div>{{JSRef}}</div>
+
+<p>O objeto <code><strong>ReferenceError</strong></code> representa um erro quando uma variável não existente é referenciada.</p>
+
+<h2 id="Sintaxe">Sintaxe</h2>
+
+<pre class="syntaxbox"><code>new ReferenceError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre>
+
+<h3 id="Parâmetros">Parâmetros</h3>
+
+<dl>
+ <dt><code>message</code></dt>
+ <dd>Opcional. Descrição legível do erro.</dd>
+ <dt><code>fileName</code> {{non-standard_inline}}</dt>
+ <dd>Opcional. O nome do arquivo contendo o código que causou a excessão.</dd>
+ <dt><code>lineNumber</code> {{non-standard_inline}}</dt>
+ <dd>Opcional. O número da linha do código que causou a excessão.</dd>
+</dl>
+
+<h2 id="Descrição">Descrição</h2>
+
+<p>O  <code>ReferenceError</code> acontece quando é feita uma tentativa de referenciar uma variável que não foi declarada.</p>
+
+<h2 id="Propriedades">Propriedades</h2>
+
+<dl>
+ <dt>{{jsxref("ReferenceError.prototype")}}</dt>
+ <dd>Permite a inclusão de propriedades em um objeto <code>ReferenceError</code>.</dd>
+</dl>
+
+<h2 id="Métodos">Métodos</h2>
+
+<p>O <code>ReferenceError</code> não contém métodos próprios, porém, ele herda alguns métodos através da cadeia de protótipos.</p>
+
+<h2 id="Instâncias_do_ReferenceError">Instâncias do <code>ReferenceError</code> </h2>
+
+<h3 id="Propriedades_2">Propriedades</h3>
+
+<div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Properties')}}</div>
+
+<h3 id="Métodos_2">Métodos</h3>
+
+<div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Methods')}}</div>
+
+<h2 id="Exemplos">Exemplos</h2>
+
+<h3 id="Capturando_um_ReferenceError">Capturando um <code>ReferenceError</code></h3>
+
+<pre class="brush: js">try {
+ var a = variavelNaoDefinida;
+} catch (e) {
+ console.log(e instanceof ReferenceError); // true
+ console.log(e.message); // "variavelNaoDefinida não está definida"
+ console.log(e.name); // "ReferenceError"
+ console.log(e.fileName); // "Scratchpad/1"
+ console.log(e.lineNumber); // 2
+ console.log(e.columnNumber); // 6
+ console.log(e.stack); // "@Scratchpad/2:2:7\n"
+}
+</pre>
+
+<h3 id="Criando_um_ReferenceError">Criando um <code>ReferenceError</code></h3>
+
+<pre class="brush: js">try {
+ throw new ReferenceError('Olá', 'arquivoQualquer.js', 10);
+} catch (e) {
+ console.log(e instanceof ReferenceError); // true
+ console.log(e.message); // "Olá"
+ console.log(e.name); // "ReferenceError"
+ console.log(e.fileName); // "arquivoQualquer.js"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // "@Scratchpad/2:2:9\n"
+}
+</pre>
+
+<h2 id="Especificações">Especificações</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Especificação</th>
+ <th scope="col">Estado</th>
+ <th scope="col">Comentário</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>Definição inicial.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.11.6.3', 'ReferenceError')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-referenceerror', 'ReferenceError')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-referenceerror', 'ReferenceError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilidade_com_browsers">Compatibilidade com browsers</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Suporte básico</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Suporte básico</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Veja_também">Veja também</h2>
+
+<ul>
+ <li>{{jsxref("Error")}}</li>
+ <li>{{jsxref("ReferenceError.prototype")}}</li>
+</ul>