diff options
Diffstat (limited to 'files/pt-pt/web/javascript/reference/global_objects/number/isnan/index.html')
-rw-r--r-- | files/pt-pt/web/javascript/reference/global_objects/number/isnan/index.html | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/files/pt-pt/web/javascript/reference/global_objects/number/isnan/index.html b/files/pt-pt/web/javascript/reference/global_objects/number/isnan/index.html deleted file mode 100644 index 0b242adbbe..0000000000 --- a/files/pt-pt/web/javascript/reference/global_objects/number/isnan/index.html +++ /dev/null @@ -1,136 +0,0 @@ ---- -title: Number.isNaN() -slug: Web/JavaScript/Reference/Global_Objects/Number/isNaN -tags: - - ECMAScript6 - - Experimental - - JavaScript - - Method - - Método(2) - - Number -translation_of: Web/JavaScript/Reference/Global_Objects/Number/isNaN ---- -<div>{{JSRef}}</div> - -<p>O método <strong><code>Number.isNaN()</code></strong> determina se o valor passado é {{jsxref("Global_Objects/NaN", "NaN")}}. Esta é uma versão mais robusta que {{jsxref("Global_Objects/isNaN", "isNaN()")}}.</p> - -<h2 id="Sintaxe">Sintaxe</h2> - -<pre class="syntaxbox"><code>Number.isNaN(valor)</code></pre> - -<h3 id="Parâmetros">Parâmetros</h3> - -<dl> - <dt><code>valor</code></dt> - <dd>O valor a ser testado se é {{jsxref("Global_Objects/NaN", "NaN")}}.</dd> -</dl> - -<h2 id="Descrição">Descrição</h2> - -<p>Due to both equality operators, {{jsxref("Operators/Comparison_Operators", "==", "#Equality")}} and {{jsxref("Operators/Comparison_Operators", "===", "#Identity")}}, evaluating to <code>false</code> when checking if {{jsxref("Global_Objects/NaN", "NaN")}} <em>is</em> {{jsxref("Global_Objects/NaN", "NaN")}}, the function <code>Number.isNaN()</code> has become necessary. This situation is unlike all other possible value comparisons in JavaScript.</p> - -<p>In comparison to the global {{jsxref("Global_Objects/isNaN", "isNaN()")}} function, <code>Number.isNaN()</code> doesn't suffer the problem of forcefully converting the parameter to a number. This means it is now safe to pass values that would normally convert to {{jsxref("Global_Objects/NaN", "NaN")}}, but aren't actually the same value as {{jsxref("Global_Objects/NaN", "NaN")}}. This also means that only values of the type number, that are also {{jsxref("Global_Objects/NaN", "NaN")}}, return <code>true</code>.</p> - -<h2 id="Exemplos">Exemplos</h2> - -<pre class="brush: js">Number.isNaN(NaN); // true -Number.isNaN(Number.NaN); // true -Number.isNaN(0 / 0) // true - -// e.g. these would have been true with global isNaN() -Number.isNaN("NaN"); // false -Number.isNaN(undefined); // false -Number.isNaN({}); // false -Number.isNaN("blabla"); // false - -// These all return false -Number.isNaN(true); -Number.isNaN(null); -Number.isNaN(37); -Number.isNaN("37"); -Number.isNaN("37.37"); -Number.isNaN(""); -Number.isNaN(" "); -</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<pre class="brush: js">Number.isNaN = Number.isNaN || function(value) { - return typeof value === "number" && isNaN(value); -}</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('ES6', '#sec-number.isnan', 'Number.isnan')}}</td> - <td>{{Spec2('ES6')}}</td> - <td>Definição inicial.</td> - </tr> - </tbody> -</table> - -<h2 id="Compatibilidade_dos_browsers">Compatibilidade dos browsers</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Funcionalidade</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome("25")}}</td> - <td>{{CompatGeckoDesktop("15")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>9</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Funcionalidade</th> - <th>Android</th> - <th>Chrome para Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile("15")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>iOS 9+</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="Ver_também">Ver também</h2> - -<ul> - <li>{{jsxref("Global_Objects/Number", "Number")}}</li> - <li>{{jsxref("Global_Objects/isNaN", "isNaN()")}}</li> -</ul> |