diff options
Diffstat (limited to 'files/es/web/javascript/reference/global_objects/rangeerror')
-rw-r--r-- | files/es/web/javascript/reference/global_objects/rangeerror/index.html | 163 | ||||
-rw-r--r-- | files/es/web/javascript/reference/global_objects/rangeerror/prototype/index.html | 130 |
2 files changed, 293 insertions, 0 deletions
diff --git a/files/es/web/javascript/reference/global_objects/rangeerror/index.html b/files/es/web/javascript/reference/global_objects/rangeerror/index.html new file mode 100644 index 0000000000..672942b3ad --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/rangeerror/index.html @@ -0,0 +1,163 @@ +--- +title: RangeError +slug: Web/JavaScript/Reference/Global_Objects/RangeError +tags: + - Error + - JavaScript + - Object + - RangeError +translation_of: Web/JavaScript/Reference/Global_Objects/RangeError +--- +<div>{{JSRef}}</div> + +<p>El objeto <code><strong>RangeError</strong></code> indica un error cuando un valor no se encuentra dentro de un rango de valores permitidos.</p> + +<h2 id="Sintaxis">Sintaxis</h2> + +<pre class="syntaxbox"><code>new RangeError([<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. Mensaje de error</dd> + <dt><code>fileName</code> {{non-standard_inline}}</dt> + <dd>Opcional. Nombre del fichero que contiene el código donde se produjo el error</dd> + <dt><code>lineNumber</code> {{non-standard_inline}}</dt> + <dd>Opcional. Número de línea de código donde se produjo el error</dd> +</dl> + +<h2 id="Descripción">Descripción</h2> + +<p>Se lanza un <code>RangeError</code> cuando se pasa como parámetro a una función un número que no está dentro del rango que dicha función permite. Esto puede ocurrir cuando se intenta crear un array con una longitud inválida con el constructor {{jsxref("Array")}}, o al pasar valores inválidos a los métodos numéricos {{jsxref("Number.toExponential()")}}, {{jsxref("Number.toFixed()")}} o {{jsxref("Number.toPrecision()")}}.</p> + +<h2 id="Propiedades">Propiedades</h2> + +<dl> + <dt>{{jsxref("RangeError.prototype")}}</dt> + <dd>Permite añadir propiedades a objetos <code>RangeError</code>.</dd> +</dl> + +<h2 id="Métodos">Métodos</h2> + +<p><code>RangeError</code> no contiene métodos, pero hereda a través de la <a href="https://developer.mozilla.org/es/docs/Web/JavaScript/Herencia_y_la_cadena_de_protipos">cadena de prototipos</a>.</p> + +<h2 id="Instancias_de_RangeError">Instancias de <code>RangeError</code></h2> + +<h3 id="Propiedades_2">Propiedades</h3> + +<div>{{page('/es/docs/Web/JavaScript/Reference/Global_Objects/RangeError/prototype', 'Propiedades')}}</div> + +<h3 id="Métodos_2">Métodos</h3> + +<div>{{page('/es/docs/Web/JavaScript/Reference/Global_Objects/RangeError/prototype', 'Métodos')}}</div> + +<h2 id="Ejemplos">Ejemplos</h2> + +<h3 id="Utilizando_RangeError">Utilizando <code>RangeError</code></h3> + +<pre class="brush: js">var check = function(num) { + if (num < MIN || num > MAX) { + throw new RangeError('El parámetro debe estar entre ' + MIN + ' y ' + MAX); + } +}; + +try { + check(500); +} +catch (e) { + if (e instanceof RangeError) { + // TODO: Manejar el error de rango + } +} +</pre> + +<h2 id="Especificaciones">Especificaciones</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificación</th> + <th scope="col">Estado</th> + <th scope="col">Comentario</th> + </tr> + <tr> + <td>{{SpecName('ES3')}}</td> + <td>{{Spec2('ES3')}}</td> + <td>Definición inical.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.11.6.2', 'RangeError')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-rangeerror', 'RangeError')}}</td> + <td>{{Spec2('ES6')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidad_en_navegadores">Compatibilidad en navegadores</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>Soporte 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>Soporte 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="Vea_también">Vea también</h2> + +<ul> + <li>{{jsxref("Error")}}</li> + <li>{{jsxref("RangeError.prototype")}}</li> + <li>{{jsxref("Array")}}</li> + <li>{{jsxref("Number.toExponential()")}}</li> + <li>{{jsxref("Number.toFixed()")}}</li> + <li>{{jsxref("Number.toPrecision()")}}</li> +</ul> diff --git a/files/es/web/javascript/reference/global_objects/rangeerror/prototype/index.html b/files/es/web/javascript/reference/global_objects/rangeerror/prototype/index.html new file mode 100644 index 0000000000..ba020719b7 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/rangeerror/prototype/index.html @@ -0,0 +1,130 @@ +--- +title: RangeError.prototype +slug: Web/JavaScript/Reference/Global_Objects/RangeError/prototype +tags: + - Error + - JavaScript + - Propiedad + - Prototipo + - Prototype + - RangeError +translation_of: Web/JavaScript/Reference/Global_Objects/RangeError +--- +<div>{{JSRef}}</div> + +<p>La propiedad <code><strong>RangeError.prototype</strong></code> representa el prototipo de {{jsxref("RangeError")}}.</p> + +<div>{{js_property_attributes(0, 0, 0)}}</div> + +<h2 id="Descripción">Descripción</h2> + +<p>Todas las instancias de {{jsxref("RangeError")}} heredan de <code>RangeError.prototype</code>. Puede utilizar el prototipo para añadir propiedades o métodos a todas las instancias.</p> + +<h2 id="Propiedades">Propiedades</h2> + +<dl> + <dt><code>RangeError.prototype.constructor</code></dt> + <dd>Especifica la función que crea instancias del prototipo.</dd> + <dt>{{jsxref("Error.prototype.message", "RangeError.prototype.message")}}</dt> + <dd>Mensaje de error. Aunque ECMA-262 especifica que {{jsxref("RangeError")}} debe procurar su propio <code>message</code>, en <a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a>, se hereda de {{jsxref("Error.prototype.message")}}.</dd> + <dt>{{jsxref("Error.prototype.name", "RangeError.prototype.name")}}</dt> + <dd>Nombre del error. Heredada de {{jsxref("Error")}}.</dd> + <dt>{{jsxref("Error.prototype.fileName", "RangeError.prototype.fileName")}}</dt> + <dd>Ruta al fichero en el que se produjo el error. Heredada de {{jsxref("Error")}}.</dd> + <dt>{{jsxref("Error.prototype.lineNumber", "RangeError.prototype.lineNumber")}}</dt> + <dd>Número de línea en el fichero en el que se produjo el error. Heredada de {{jsxref("Error")}}.</dd> + <dt>{{jsxref("Error.prototype.columnNumber", "RangeError.prototype.columnNumber")}}</dt> + <dd>Número de columna de la línea en la que se produjo. Heredada de {{jsxref("Error")}}.</dd> + <dt>{{jsxref("Error.prototype.stack", "RangeError.prototype.stack")}}</dt> + <dd>Pila de llamadas. Heredada de {{jsxref("Error")}}.</dd> +</dl> + +<h2 id="Métodos">Métodos</h2> + +<p>Aunque el prototipo del objeto {{jsxref("RangeError")}} no contiene métodos propios, las instancias de {{jsxref("RangeError")}} heredan algunos a través de la <a href="https://developer.mozilla.org/es/docs/Web/JavaScript/Herencia_y_la_cadena_de_protipos">cadena de prototipos</a>.</p> + +<h2 id="Especificaciones">Especificaciones</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificación</th> + <th scope="col">Estado</th> + <th scope="col">Commentario</th> + </tr> + <tr> + <td>{{SpecName('ES3')}}</td> + <td>{{Spec2('ES3')}}</td> + <td>Definición inicial.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.11.7.6', 'NativeError.prototype')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td>Definido como <code><em>NativeError</em>.prototype</code>.</td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-nativeerror.prototype', 'NativeError.prototype')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Definido como <code><em>NativeError</em>.prototype</code>.</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidad_de_navegadores">Compatibilidad de navegadores</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>Soporte 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>Soporte 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="Vea_también">Vea también</h2> + +<ul> + <li>{{jsxref("Error.prototype")}}</li> + <li>{{jsxref("Function.prototype")}}</li> +</ul> |