-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into usage-notes
- Loading branch information
Showing
13 changed files
with
172 additions
and
34 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
files/es/web/javascript/reference/global_objects/map/foreach/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
--- | ||
title: Map.prototype.forEach() | ||
slug: Web/JavaScript/Reference/Global_Objects/Map/forEach | ||
l10n: | ||
sourceCommit: 27180875516cc311342e74b596bfb589b7211e0c | ||
--- | ||
|
||
{{JSRef}} | ||
|
||
El método **`forEach()`** de las instancias de {{jsxref("Map")}} ejecuta la función provista, una vez por cada tupla llave/valor en este _map_, en orden de inserción. | ||
|
||
{{EmbedInteractiveExample("pages/js/map-prototype-foreach.html")}} | ||
|
||
## Sintaxis | ||
|
||
```js-nolint | ||
forEach(callbackFn) | ||
forEach(callbackFn, thisArg) | ||
``` | ||
|
||
### Parámetro | ||
|
||
- `callbackFn` | ||
- : Una función que se ejecuta por cada entrada en el _map_. La función es llamada con los siguientes argumentos: | ||
- `value` | ||
- : El valor de cada iteración. | ||
- `key` | ||
- : La llave de cada iteración. | ||
- `map` | ||
- : El _map_ que esta siendo iterado. | ||
- `thisArg` {{optional_inline}} | ||
- : Un valor que se usa como `this` cuando se ejecuta la función `callbackFn`. | ||
|
||
### Valor devuelto | ||
|
||
Ningúno ({{jsxref("undefined")}}). | ||
|
||
## Descripción | ||
|
||
El método `forEach` ejecuta la función `callback` provista, una vez por cada llave que actualmente existe en el _map_. No se invoca para llaves que fueron borradas. Sin embargo, la función es ejecutada para valores que se encuentran en el objeto, pero que su valor es `undefined`. | ||
|
||
La función `callback` es invocada con **tres argumentos**: | ||
|
||
- el `value` del elemento | ||
- el `key` del elemento | ||
- el **objeto `Map`** que se esta iterando | ||
|
||
Si el parámetro `thisArg` se provee a la función `forEach`, este se pasará a la función `callback` cuando sea invocada, para usarse como el valor `this`. De lo contrario, el valor `undefined` será pasado para usarse como el valor `this`. El valor `this` que finalmente es visible para la función `callback`, es determinado de acuerdo a [las reglas para determinar el valor `this` visible para una función](/es/docs/Web/JavaScript/Reference/Operators/this). | ||
|
||
Cada valor es visitado una vez, excepto en el caso en que el valor es borrado y agregado antes de que `forEach` haya terminado. La función `callback` no es invocada para valores que se borraron antes de ser visitados. Los valores agregados antes de que `forEach` termine, serán visitados. | ||
|
||
## Ejemplos | ||
|
||
### Imprimiendo el contenido de un objeto Map | ||
|
||
El siguiente código, registra en la consola un mensaje por cada elemento en un objeto `Map`: | ||
|
||
```js | ||
function logMapElements(value, key, map) { | ||
console.log(`map.get('${key}') = ${value}`); | ||
} | ||
new Map([ | ||
["foo", 3], | ||
["bar", {}], | ||
["baz", undefined], | ||
]).forEach(logMapElements); | ||
// Logs: | ||
// "map.get('foo') = 3" | ||
// "map.get('bar') = [object Object]" | ||
// "map.get('baz') = undefined" | ||
``` | ||
|
||
## Especificaciones | ||
|
||
{{Specifications}} | ||
|
||
## Compatibilidad con navegadores | ||
|
||
{{Compat}} | ||
|
||
## Véase también | ||
|
||
- {{jsxref("Array.prototype.forEach()")}} | ||
- {{jsxref("Set.prototype.forEach()")}} |
41 changes: 41 additions & 0 deletions
41
files/es/web/javascript/reference/global_objects/map/size/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: Map.prototype.size | ||
slug: Web/JavaScript/Reference/Global_Objects/Map/size | ||
l10n: | ||
sourceCommit: 6a0f9553932823cd0c4dcf695d4b4813474964fb | ||
--- | ||
|
||
{{JSRef}} | ||
|
||
La propiedad de acceso **`size`** de las instancias {{jsxref("Map")}} regresa el número de elementos de este _map_. | ||
|
||
{{EmbedInteractiveExample("pages/js/map-prototype-size.html")}} | ||
|
||
## Descripción | ||
|
||
El valor de `size` es un entero que representa, el número de entradas que el objeto `Map` tiene. La función de acceso para `size` es `undefined`; no puedes modificar esta propiedad. | ||
|
||
## Ejemplos | ||
|
||
### Usando size | ||
|
||
```js | ||
const myMap = new Map(); | ||
myMap.set("a", "alpha"); | ||
myMap.set("b", "beta"); | ||
myMap.set("g", "gamma"); | ||
|
||
console.log(myMap.size); // 3 | ||
``` | ||
|
||
## Especificaciones | ||
|
||
{{Specifications}} | ||
|
||
## Compatibilidad con nvegadores | ||
|
||
{{Compat}} | ||
|
||
## Véase también | ||
|
||
- {{jsxref("Map")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...s/ko/web/http/resources_and_uris/index.md → ...b/http/basics_of_http/mime_types/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...identifying_resources_on_the_web/index.md → ...identifying_resources_on_the_web/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ing_between_www_and_non-www_urls/index.md → ...ing_between_www_and_non-www_urls/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...eb/http/basics_of_http/data_urls/index.md → files/ko/web/uri/schemes/data/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ttp/basics_of_http/resource_urls/index.md → files/ko/web/uri/schemes/resource/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...identifying_resources_on_the_web/index.md → ...identifying_resources_on_the_web/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...eb/http/basics_of_http/data_urls/index.md → files/ru/web/uri/schemes/data/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: Data URL | ||
slug: Web/HTTP/Basics_of_HTTP/Data_URLs | ||
slug: Web/URI/Schemes/data | ||
--- | ||
|
||
{{HTTPSidebar}} | ||
|