Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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