diff options
| author | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:46:50 +0100 |
|---|---|---|
| committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:46:50 +0100 |
| commit | a55b575e8089ee6cab7c5c262a7e6db55d0e34d6 (patch) | |
| tree | 5032e6779a402a863654c9d65965073f09ea4182 /files/es/web/javascript/reference/global_objects/number/parseint/index.html | |
| parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
| download | translated-content-a55b575e8089ee6cab7c5c262a7e6db55d0e34d6.tar.gz translated-content-a55b575e8089ee6cab7c5c262a7e6db55d0e34d6.tar.bz2 translated-content-a55b575e8089ee6cab7c5c262a7e6db55d0e34d6.zip | |
unslug es: move
Diffstat (limited to 'files/es/web/javascript/reference/global_objects/number/parseint/index.html')
| -rw-r--r-- | files/es/web/javascript/reference/global_objects/number/parseint/index.html | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/files/es/web/javascript/reference/global_objects/number/parseint/index.html b/files/es/web/javascript/reference/global_objects/number/parseint/index.html new file mode 100644 index 0000000000..e899827599 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/number/parseint/index.html @@ -0,0 +1,80 @@ +--- +title: Number.parseInt() +slug: Web/JavaScript/Referencia/Objetos_globales/Number/parseInt +tags: + - metodo +translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseInt +--- +<div>{{JSRef}}</div> + +<p>The <strong><code>Number.parseInt()</code></strong> method parses a string argument and returns an integer of the specified radix or base.</p> + +<p>The <strong><code>Number.parseInt()</code></strong> El método Number.parseInt () analiza un argumento de cadena y devuelve un entero de la raíz o base especificada.</p> + +<div>{{EmbedInteractiveExample("pages/js/number-parseint.html", "taller")}}</div> + + + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox">Number.parseInt(<var>string,</var>[ <var>radix</var>])</pre> + +<h3 id="Parameters">Parameters</h3> + +<div> +<dl> + <dt><code><var>string</var></code></dt> + <dd>The value to parse. If this argument is not a string, then it is converted to one using the <code><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></code> abstract operation. Leading whitespace in this argument is ignored.</dd> + <dt><code><var>radix</var></code><var> {{optional_inline}}</var></dt> + <dd>An integer between <code>2</code> and <code>36</code> that represents the <em>radix</em> (the base in mathematical numeral systems) of the <code><var>string</var></code>. Be careful—this does <strong><em>not</em></strong> default to <code>10</code>!</dd> +</dl> +</div> + +<h3 id="Return_value">Return value</h3> + +<p>An integer parsed from the given <code><var>string</var></code>.</p> + +<p>If the <code><var>radix</var></code> is smaller than <code>2</code> or bigger than <code>36</code>, and the first non-whitespace character cannot be converted to a number, {{jsxref("NaN")}} is returned.</p> + +<h2 id="Description">Description</h2> + +<p>This method has the same functionality as the global {{jsxref("parseInt", "parseInt()")}} function:</p> + +<pre class="brush: js">Number.parseInt === parseInt // true</pre> + +<p>and is part of ECMAScript 2015 (its purpose is modularization of globals). Please see {{jsxref("parseInt", "parseInt()")}} for more detail and examples.</p> + +<h2 id="Polyfill">Polyfill</h2> + +<pre class="brush: js">if (Number.parseInt === undefined) { + Number.parseInt = window.parseInt +} +</pre> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('ESDraft', '#sec-number.parseint', 'Number.parseInt')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("javascript.builtins.Number.parseInt")}}</p> + +<h2 id="See_also">See also</h2> + +<ul> + <li>The {{jsxref("Number")}} object it belongs to.</li> + <li>The global {{jsxref("parseInt", "parseInt()")}} method.</li> +</ul> |
