From a55b575e8089ee6cab7c5c262a7e6db55d0e34d6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:46:50 +0100 Subject: unslug es: move --- .../global_objects/array/@@species/index.html | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 files/es/web/javascript/reference/global_objects/array/@@species/index.html (limited to 'files/es/web/javascript/reference/global_objects/array/@@species') diff --git a/files/es/web/javascript/reference/global_objects/array/@@species/index.html b/files/es/web/javascript/reference/global_objects/array/@@species/index.html new file mode 100644 index 0000000000..2f15ad345a --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/array/@@species/index.html @@ -0,0 +1,76 @@ +--- +title: 'get Array[@@species]' +slug: Web/JavaScript/Referencia/Objetos_globales/Array/@@species +tags: + - Array + - JavaScript + - Prototipo + - metodo +translation_of: Web/JavaScript/Reference/Global_Objects/Array/@@species +--- +
{{JSRef}}
+ +

La propiedad de acceso Array[@@species] devuelve el constructor de Array.

+ +

Sintaxis

+ +
Array[Symbol.species]
+
+ +

Valor de retorno

+ +

El constructor {{jsxref("Array")}}.

+ +

Descripción

+ +

La propiedad de acceso species devuelve el constructor predeterminado para objetos Array. Los constructores de subclase pueden anularlo para cambiar la asignación del constructor.

+ +

Ejemplos

+ +

La propiedad species devuelve la función de constructor predeterminada, que es el constructor Array para objetos Array:

+ +
Array[Symbol.species]; // function Array()
+ +

In a derived collection object (e.g. your custom array MyArray), the MyArray species is the MyArray constructor. However, you might want to overwrite this, in order to return parent Array objects in your derived class methods:

+ +
class MyArray extends Array {
+  // Overwrite MyArray species to the parent Array constructor
+  static get [Symbol.species]() { return Array; }
+}
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES6', '#sec-get-array-@@species', 'get Array [ @@species ]')}}{{Spec2('ES6')}}Definición inicial.
{{SpecName('ESDraft', '#sec-get-array-@@species', 'get Array [ @@species ]')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad con navegadores

+ +
+ + +

{{Compat("javascript.builtins.Array.@@species")}}

+
+ +

Ver también

+ + -- cgit v1.2.3-54-g00ecf