Skip to content

Commit

Permalink
Convert /web/javascript/reference/global_objects/array folder to Mark…
Browse files Browse the repository at this point in the history
…down (es) (#8169)

* Convert /web/javascript/reference/global_objects/array folder to Markdown (es)

* Apply suggestions from code review

Authored by: Queen Vinyl Da.i'gyu-Kazotetsu <[email protected]>
Co-authored-by: GrayWolf <[email protected]>
  • Loading branch information
Graywolf9 committed Sep 28, 2022
1 parent a4b987b commit 266e96f
Show file tree
Hide file tree
Showing 58 changed files with 3,835 additions and 4,442 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: Array.prototype[@@iterator]()
slug: Web/JavaScript/Reference/Global_Objects/Array/@@iterator
tags:
- Array
- ECMAScript 2015
- Iterator
- JavaScript
- Prototipo
- Referencia
- metodo
translation_of: Web/JavaScript/Reference/Global_Objects/Array/@@iterator
original_slug: Web/JavaScript/Referencia/Objetos_globales/Array/@@iterator
---
{{JSRef}}

El valor inicial de la propiedad **`@@iterator`** es el mismo objeto de función que el valor inicial de la propiedad {{jsxref("Array.prototype.values()", "values()")}}.

## Sintaxis

arr[Symbol.iterator]()

### Valor de retorno

El valor inicial dado por el **iterador** {{jsxref("Array.prototype.values()", "values()")}}. Por defecto, usar `arr[Symbol.iterator]` devolverá la función {{jsxref("Array.prototype.values()", "values()")}}.

## Ejemplos

### Iteración usando el bucle `for...of`

```js
var arr = ['w', 'y', 'k', 'o', 'p'];
var eArr = arr[Symbol.iterator]();
// nuestro navegador debe ser compatible con el bucle for..of
// y variables let-scoped en bucles for
for (let letter of eArr) {
console.log(letter);
}
```

### Iteración alternativa

```js
var arr = ['w', 'y', 'k', 'o', 'p'];
var eArr = arr[Symbol.iterator]();
console.log(eArr.next().value); // w
console.log(eArr.next().value); // y
console.log(eArr.next().value); // k
console.log(eArr.next().value); // o
console.log(eArr.next().value); // p
```

## Especificaciones

| Especificación | Estado | Comentario |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------- | -------------------- |
| {{SpecName('ES2015', '#sec-array.prototype-@@iterator', 'Array.prototype[@@iterator]()')}} | {{Spec2('ES2015')}} | Definición inicial.. |
| {{SpecName('ESDraft', '#sec-array.prototype-@@iterator', 'Array.prototype[@@iterator]()')}} | {{Spec2('ESDraft')}} | |

## Compatibilidad con navegadores

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

## Ver también

- {{jsxref("Array.prototype.keys()")}}
- {{jsxref("Array.prototype.entries()")}}
- {{jsxref("Array.prototype.forEach()")}}
- {{jsxref("Array.prototype.every()")}}
- {{jsxref("Array.prototype.some()")}}
- {{jsxref("Array.prototype.values()")}}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: get Array[@@species]
slug: Web/JavaScript/Reference/Global_Objects/Array/@@species
tags:
- Array
- JavaScript
- Prototipo
- metodo
translation_of: Web/JavaScript/Reference/Global_Objects/Array/@@species
original_slug: Web/JavaScript/Referencia/Objetos_globales/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`:

```js
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:

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

## Especificaciones

| Especificación | Estado | Comentario |
| -------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------- |
| {{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

- {{jsxref("Array")}}
- {{jsxref("Symbol.species")}}

This file was deleted.

Loading

0 comments on commit 266e96f

Please sign in to comment.