aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/javascript/reference/global_objects/array/isarray
diff options
context:
space:
mode:
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/array/isarray')
-rw-r--r--files/pt-br/web/javascript/reference/global_objects/array/isarray/index.html141
1 files changed, 141 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/array/isarray/index.html b/files/pt-br/web/javascript/reference/global_objects/array/isarray/index.html
new file mode 100644
index 0000000000..328790b8e9
--- /dev/null
+++ b/files/pt-br/web/javascript/reference/global_objects/array/isarray/index.html
@@ -0,0 +1,141 @@
+---
+title: Array.isArray()
+slug: Web/JavaScript/Reference/Global_Objects/Array/isArray
+translation_of: Web/JavaScript/Reference/Global_Objects/Array/isArray
+---
+<div>{{JSRef("Global_Objects", "Array")}}</div>
+
+<h2 id="Summary" name="Summary">Sumário</h2>
+
+<p><font face="Open Sans, Arial, sans-serif">O método </font><code><strong>Array.isArray()</strong></code> retorna <code>true</code> se um objeto é uma array, e <code>false</code> se não é.</p>
+
+<h2 id="Syntax" name="Syntax">Sintaxe</h2>
+
+<pre class="syntaxbox"><code>Array.isArray(<var>obj</var>)</code></pre>
+
+<h3 id="Parameters" name="Parameters">Parâmetros</h3>
+
+<dl>
+ <dt><code>obj</code></dt>
+ <dd>O objeto a ser verificado.</dd>
+</dl>
+
+<h2 id="Description" name="Description">Descrição</h2>
+
+<p>Se o objeto é um {{jsxref("Array")}}, retorna <code>true</code>(verdadeiro), caso contrário é retornado <code>false</code>(falso).</p>
+
+<p>Veja o artigo <a href="http://web.mit.edu/jwalden/www/isArray.html">“Determinando com absoluta precisão se um objeto em Javascript é ou não uma array”</a> para mais detalhes.</p>
+
+<h2 id="Examples" name="Examples">Exemplos</h2>
+
+<pre class="brush: js">// todas as chamadas conseguintes retornam <code style="font-style: normal;">true</code>
+Array.isArray([]);
+Array.isArray([1]);
+Array.isArray(new Array());
+// Pequeno detalhe: Array.prototype por si só é uma array:
+Array.isArray(Array.prototype);
+
+// todas as conseguintes retornam false
+Array.isArray();
+Array.isArray({});
+Array.isArray(null);
+Array.isArray(undefined);
+Array.isArray(17);
+Array.isArray('Array');
+Array.isArray(true);
+Array.isArray(false);
+Array.isArray({ __proto__: Array.prototype });
+</pre>
+
+<h2 id="Polyfill" name="Polyfill">Polyfill</h2>
+
+<p>Executando o seguinte código antes de qualquer outro, o método <code>Array.isArray()</code> será criado, caso o browser não o disponibilize nativamente.</p>
+
+<pre class="brush: js">if (!Array.isArray) {
+ Array.isArray = function(arg) {
+ return Object.prototype.toString.call(arg) === '[object Array]';
+ };
+}
+</pre>
+
+<h2 id="Specifications" name="Specifications">Especificações</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Especificação</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comentário</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.4.3.2', 'Array.isArray')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>Definição Inicial. Implementado em JavaScript 1.8.5.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-array.isarray', 'Array.isArray')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidade com o Browser</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</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>{{CompatChrome("5")}}</td>
+ <td>{{CompatGeckoDesktop("2.0")}}</td>
+ <td>{{CompatIE("9")}}</td>
+ <td>{{CompatOpera("10.5")}}</td>
+ <td>{{CompatSafari("5")}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</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>{{CompatGeckoMobile("2.0")}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>Baseado na <a href="http://kangax.github.com/es5-compat-table/">Tabela de Compatibilidade de Kangax</a>.</p>
+
+<h2 id="See_also" name="See_also">Veja Também</h2>
+
+<ul>
+ <li>{{jsxref("Global_Objects/Array", "Array")}}</li>
+</ul>