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/set/@@iterator/index.html | 86 ++++++++ .../reference/global_objects/set/add/index.html | 124 +++++++++++ .../reference/global_objects/set/clear/index.html | 119 +++++++++++ .../reference/global_objects/set/delete/index.html | 117 +++++++++++ .../global_objects/set/entries/index.html | 71 +++++++ .../reference/global_objects/set/has/index.html | 124 +++++++++++ .../reference/global_objects/set/index.html | 230 +++++++++++++++++++++ .../reference/global_objects/set/size/index.html | 106 ++++++++++ .../reference/global_objects/set/values/index.html | 72 +++++++ 9 files changed, 1049 insertions(+) create mode 100644 files/es/web/javascript/reference/global_objects/set/@@iterator/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/add/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/clear/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/delete/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/entries/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/has/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/size/index.html create mode 100644 files/es/web/javascript/reference/global_objects/set/values/index.html (limited to 'files/es/web/javascript/reference/global_objects/set') diff --git a/files/es/web/javascript/reference/global_objects/set/@@iterator/index.html b/files/es/web/javascript/reference/global_objects/set/@@iterator/index.html new file mode 100644 index 0000000000..7445821fc0 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/@@iterator/index.html @@ -0,0 +1,86 @@ +--- +title: 'Set.prototype[@@iterator]()' +slug: Web/JavaScript/Referencia/Objetos_globales/Set/@@iterator +tags: + - Iteradores +translation_of: Web/JavaScript/Reference/Global_Objects/Set/@@iterator +--- +
{{JSRef}}
+ +

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

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-@@iterator.html")}}
+ + + +

Sintaxis

+ +
mySet[Symbol.iterator]
+ +

 Valor retornado

+ +

La función iteradora Set , la cuál es {{jsxref("Set.prototype.values()", "values()")}} por defecto.

+ +

Ejemplos

+ +

Usando [@@iterator]()

+ +
const mySet = new Set();
+mySet.add('0');
+mySet.add(1);
+mySet.add({});
+
+const setIter = mySet[Symbol.iterator]();
+
+console.log(setIter.next().value); // "0"
+console.log(setIter.next().value); // 1
+console.log(setIter.next().value); // Object
+
+ +

Usando [@@iterator]() con for..of

+ +
const mySet = new Set();
+mySet.add('0');
+mySet.add(1);
+mySet.add({});
+
+for (const v of mySet) {
+  console.log(v);
+}
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES2015', '#sec-set.prototype-@@iterator', 'Set.prototype[@@iterator]')}}{{Spec2('ES2015')}}Definición inicial.
{{SpecName('ESDraft', '#sec-set.prototype-@@iterator', 'Set.prototype[@@iterator]')}}{{Spec2('ESDraft')}}
+ +

Compatibilidad en navegadores

+ + + +

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

+ +

Vea también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/add/index.html b/files/es/web/javascript/reference/global_objects/set/add/index.html new file mode 100644 index 0000000000..f9385894fb --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/add/index.html @@ -0,0 +1,124 @@ +--- +title: Set.prototype.add() +slug: Web/JavaScript/Referencia/Objetos_globales/Set/add +translation_of: Web/JavaScript/Reference/Global_Objects/Set/add +--- +
{{JSRef}}
+ +

El método add() añade un nuevo elemento con un valor específico al final del objeto Set.

+ +

Sintaxis

+ +
mySet.add(value);
+ +

Parameters

+ +
+
value
+
Requerido. El valor del elemento a ser añadido al objeto Set.
+
+ +

Return value

+ +

El objeto Set.

+ +

Ejemplos

+ +

Usando el método add

+ +
var mySet = new Set();
+
+mySet.add(1);
+mySet.add(5).add("some text"); // chainable
+
+console.log(mySet);
+// Set [1, 5, "some text"]
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES6', '#sec-set.prototype.add', 'Set.prototype.add')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.add', 'Set.prototype.add')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support38{{CompatGeckoDesktop("13.0")}}11257.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}38{{CompatGeckoMobile("13.0")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Firefox-specific notes

+ + + +

See also

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/clear/index.html b/files/es/web/javascript/reference/global_objects/set/clear/index.html new file mode 100644 index 0000000000..0fdca7e492 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/clear/index.html @@ -0,0 +1,119 @@ +--- +title: Set.prototype.clear() +slug: Web/JavaScript/Referencia/Objetos_globales/Set/clear +tags: + - ECMAScript6 + - JavaScript + - Prototype + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear +--- +
{{JSRef}}
+ +

El método clear() remueve todos los elementos de un objeto Set.

+ +

Syntaxis

+ +
mySet.clear();
+ +

Valor de retorno

+ +

{{jsxref("undefined")}}.

+ +

Ejemplos

+ +

Usando el método clear

+ +
var mySet = new Set();
+mySet.add(1);
+mySet.add("foo");
+
+mySet.size;       // 2
+mySet.has("foo"); // true
+
+mySet.clear();
+
+mySet.size;       // 0
+mySet.has("bar")  // false
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES6', '#sec-set.prototype.clear', 'Set.prototype.clear')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.clear', 'Set.prototype.clear')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad de navegadores

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico38{{CompatGeckoDesktop("19.0")}}11257.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Soporte básico{{CompatNo}}25{{CompatGeckoMobile("19.0")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Ver también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/delete/index.html b/files/es/web/javascript/reference/global_objects/set/delete/index.html new file mode 100644 index 0000000000..3e5544e06a --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/delete/index.html @@ -0,0 +1,117 @@ +--- +title: Set.prototype.delete() +slug: Web/JavaScript/Referencia/Objetos_globales/Set/delete +translation_of: Web/JavaScript/Reference/Global_Objects/Set/delete +--- +
{{JSRef}}
+ +

El método delete() remueve el elemento especificado del objeto Set.

+ +

Syntaxis

+ +
mySet.delete(value);
+ +

Parametros

+ +
+
valor
+
Requerido. El valor del elemento a remover del objeto Set.
+
+ +

Valor de retorno

+ +

true si el elemento ha sido removido exitosamente en el Set; de otra manera retorna false.

+ +

Ejemplos

+ +

Usando el método delete

+ +
var mySet = new Set();
+mySet.add("foo");
+
+mySet.delete("bar"); // Retorna false. No hay elemento "bar" para ser removido.
+mySet.delete("foo"); // Retorna true.  Removido exitosamente.
+
+mySet.has("foo");    // Retorna false. El elemento "foo" ya no está presente.
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES6', '#sec-set.prototype.delete', 'Set.prototype.delete')}}{{Spec2('ES6')}}Definición inicial.
{{SpecName('ESDraft', '#sec-set.prototype.delete', 'Set.prototype.delete')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad de navegadores

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico38{{CompatGeckoDesktop("13.0")}}11257.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Soporte básico{{CompatNo}}38{{CompatGeckoMobile("13.0")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Ver también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/entries/index.html b/files/es/web/javascript/reference/global_objects/set/entries/index.html new file mode 100644 index 0000000000..ba07d24187 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/entries/index.html @@ -0,0 +1,71 @@ +--- +title: Set.prototype.entries() +slug: Web/JavaScript/Referencia/Objetos_globales/Set/entries +translation_of: Web/JavaScript/Reference/Global_Objects/Set/entries +--- +
{{JSRef}}
+ +

El método entries() devuelve un nuevo objeto de tipo Iterator que contiene un array de tuplas [value, value] por cada elemento en el Set original, manteniendo el orden de inserción. En los objetos de tipo Set no existe una clave key como ocurre en los objetos de tipo Map. Sin embargo, para mantener una API similar a la de los objetos de tipo Map, cada entry contiene el mismo valor para su clave y valor, devolviendo por tanto un array de tuplas [value, value].

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-entries.html")}}
+ + + +

Sintaxis

+ +
mySet.entries()
+ +

Valor de retorno

+ +

Un nuevo objeto de tipo Iterator que contiene un array de tuplas [value, value] por cada elemento en el Set original, en orden de inserción.

+ +

Ejemplos

+ +

Usando el método entries

+ +
var mySet = new Set();
+mySet.add('foobar');
+mySet.add(1);
+mySet.add('baz');
+
+var setIter = mySet.entries();
+
+console.log(setIter.next().value); // ["foobar", "foobar"]
+console.log(setIter.next().value); // [1, 1]
+console.log(setIter.next().value); // ["baz", "baz"]
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoCommentario
{{SpecName('ES2015', '#sec-set.prototype.entries', 'Set.prototype.entries')}}{{Spec2('ES2015')}}Definición inicial.
{{SpecName('ESDraft', '#sec-set.prototype.entries', 'Set.prototype.entries')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad de navegadores

+ + + +

{{Compat("javascript.builtins.Set.entries")}}

+ +

Ver también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/has/index.html b/files/es/web/javascript/reference/global_objects/set/has/index.html new file mode 100644 index 0000000000..e133de2d00 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/has/index.html @@ -0,0 +1,124 @@ +--- +title: Set.prototype.has() +slug: Web/JavaScript/Referencia/Objetos_globales/Set/has +tags: + - ECMAScript6 + - JavaScript + - Prototype + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set/has +--- +
{{JSRef}}
+ +

El método has() retorna un booleano indicando si el elemento especificado existe en el objeto Set o no.

+ +

Syntaxis

+ +
mySet.has(value);
+ +

Parametros

+ +
+
valor
+
Requerido. El valor del cual se probará su presencia en el objeto Set.
+
+ +

Valor de retorno

+ +
+
Booleano
+
Retorna true si el elemento con el valor especificado existe en el objeto  Set; de otra manera retorna false.
+
+ +

Ejemplos

+ +

Usando el método has

+ +
var mySet = new Set();
+mySet.add("foo");
+
+mySet.has("foo");  // retorna true
+mySet.has("bar");  // retorna false
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES6', '#sec-set.prototype.has', 'Set.prototype.has')}}{{Spec2('ES6')}}Definición inicial.
{{SpecName('ESDraft', '#sec-set.prototype.has', 'Set.prototype.has')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad de navegadores

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico38{{CompatGeckoDesktop("13.0")}}11257.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Soporte básico{{CompatNo}}38{{CompatGeckoMobile("13.0")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Ver también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/index.html b/files/es/web/javascript/reference/global_objects/set/index.html new file mode 100644 index 0000000000..db091b3a59 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/index.html @@ -0,0 +1,230 @@ +--- +title: Set +slug: Web/JavaScript/Referencia/Objetos_globales/Set +tags: + - ECMAScript 2015 + - JavaScript + - Object + - set +translation_of: Web/JavaScript/Reference/Global_Objects/Set +--- +
{{JSRef}}
+ +

El objeto Set permite almacenar valores únicos de cualquier tipo, incluso {{Glossary("Primitive", "valores primitivos")}} u referencias a objetos.

+ +

Sintaxis

+ +
new Set([iterable]);
+ +

Parámetros

+ +
+
iterable
+
Si un objeto iterable es pasado, todos sus elementos serán añadidos al nuevo Set. Si no se especifica este parámetro, o si su valor es null, el nuevo Set estará vacío.
+
+ +

Valor retornado

+ +

Una nueva instancia de Set.

+ +

Descripción

+ +

Los objetos Set son colecciones de valores. Se puede iterar sus elementos en el orden de su inserción. Un valor en un Set sólo puede estar una vez; éste es único en la colección Set.

+ +

Igualdad de valores

+ +

Ya que cada valor en el Set tiene que ser único, la igualdad del valor será comprobada y esta igualdad no se basa en el mismo algoritmo usado en el operador ===. Específicamente, para Sets, +0 (el cual es estrictamente igual a -0) y -0 son valores distintos. Sin embargo, esto ha cambiado en la última especificación ECMAScript 6. Iniciando con Gecko 29.0 {{geckoRelease("29")}} ({{bug("952870")}}) y un recent nightly Chrome, +0-0 son tratados como el mismo valor en objetos Set

+ +

NaN y undefined también pueden ser almacenados en un Set. NaN es considerado igual que NaN (A pesar que NaN !== NaN).

+ +

Propiedades

+ +
+
Set.length
+
El valor de la propiedad length es 0.
+
{{jsxref("Set.@@species", "get Set[@@species]")}}
+
La función constructora que es usada para crear objetos derivados.
+
{{jsxref("Set.prototype")}}
+
Representa el prototipo para el constructor Set. Permite la adición de propiedades a todos los objetos Set.
+
+ +

Instancias Set

+ +

Todas las instancias de Set heredan de {{jsxref("Set.prototype")}}.

+ +

Propiedades

+ +

{{page('en-US/Web/JavaScript/Reference/Global_Objects/Set/prototype','Properties')}}

+ +

Métodos

+ +

{{page('en-US/Web/JavaScript/Reference/Global_Objects/Set/prototype','Methods')}}

+ +

Ejemplos

+ +

Usando el objeto Set

+ +
const mySet = new Set();
+
+mySet.add(1);
+mySet.add(5);
+mySet.add('some text');
+
+const o = {a: 1, b: 2};
+mySet.add(o);
+
+mySet.add({a: 1, b: 2}); // La variable "o" referencia a otro objeto, por lo que agrega otro valor.
+
+mySet.has(1); // true
+mySet.has(3); // false, 3 no ha sido añadido al Set
+mySet.has(5);              // true
+mySet.has(Math.sqrt(25));  // true
+mySet.has('Some Text'.toLowerCase()); // true
+mySet.has(o); // true
+
+mySet.size; // 5
+
+mySet.delete(5); // Elimina 5 del Set
+mySet.has(5);    // false, 5 fue eliminado
+
+mySet.size; // 4, sólo removimos un valor
+console.log(mySet);// Set {1, "some text", Object {a: 1, b: 2}, Object {a: 1, b: 2}}
+ +

Iterando los Sets

+ +
// iterar todos los items de un set
+// imprimir en consola los items en orden: 1, 'some text', {a: 1, b: 2}
+for (let item of mySet) console.log(item);
+
+// imprimir en consola los items en orden: 1, 'some text', {a: 1, b: 2}
+for (let item of mySet.keys()) console.log(item);
+
+// imprimir en consola los items en orden: 1, 'some text', {a: 1, b: 2}
+for (let item of mySet.values()) console.log(item);
+
+// imprimir en consola los items en orden: 1, 'some text', {a: 1, b: 2}
+//(key y value poseen en mismo valor en este caso)
+for (let [key, value] of mySet.entries()) console.log(key);
+
+// crear un Array plano con los mismos valores, utilizando Array.from
+const myArr = Array.from(mySet); // [1, 'some text', {a: 1, b: 2}]
+
+// también se puede utilizar para guardar elementos del DOM
+mySet.add(document.body);
+mySet.has(document.querySelector('body')); // true
+
+// crear un Array plano con los mismos valores, utilizando propagación
+const mySet2 = new Set([1,2,3,4]);
+mySet2.size; // 4
+[...mySet2]; // [1,2,3,4]
+
+// la intersección entre dos sets puede ser simulada con
+const intersection = new Set([...set1].filter(x => set2.has(x)));
+
+// la diferencia puede ser simulada con
+const difference = new Set([...set1].filter(x => !set2.has(x)));
+
+// Iteración utilizando forEach
+mySet.forEach((value) => {
+  console.log(value);
+});
+
+// 1
+// 2
+// 3
+// 4
+ +

Implementando operaciones básicas

+ +
Set.prototype.isSuperset = function(subset) {
+    for (var elem of subset) {
+        if (!this.has(elem)) {
+            return false;
+        }
+    }
+    return true;
+}
+
+Set.prototype.union = function(setB) {
+    var union = new Set(this);
+    for (var elem of setB) {
+        union.add(elem);
+    }
+    return union;
+}
+
+Set.prototype.intersection = function(setB) {
+    var intersection = new Set();
+    for (var elem of setB) {
+        if (this.has(elem)) {
+            intersection.add(elem);
+        }
+    }
+    return intersection;
+}
+
+Set.prototype.difference = function(setB) {
+    var difference = new Set(this);
+    for (var elem of setB) {
+        difference.delete(elem);
+    }
+    return difference;
+}
+
+//Examples
+var setA = new Set([1,2,3,4]),
+    setB = new Set([2,3]),
+    setC = new Set([3,4,5,6]);
+
+setA.isSuperset(setB); // => true
+setA.union(setC); // => Set [1, 2, 3, 4, 5, 6]
+setA.intersection(setC); // => Set [3, 4]
+setA.difference(setC); // => Set [1, 2]
+ +

Relación con los objetos Array

+ +
const myArray = ['value1', 'value2', 'value3'];
+
+// Utiliza el constructor para para crear un set con el mismo contenido que un array
+const mySet = new Set(myArray);
+
+mySet.has('value1'); // devuelve true
+
+// Utiliza la propagación para crear un array con los contenidos de un set
+console.log([...mySet]); // Muestra lo mismo utilizando myArray
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('ES2015', '#sec-set-objects', 'Set')}}{{Spec2('ES2015')}}Definición inicial
{{SpecName('ESDraft', '#sec-set-objects', 'Set')}}{{Spec2('ESDraft')}}
+ +

Compatibilidad de navegadores

+ + + +

{{Compat("javascript.builtins.Set")}}

+ +

Ver también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/size/index.html b/files/es/web/javascript/reference/global_objects/set/size/index.html new file mode 100644 index 0000000000..444ad7ae8a --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/size/index.html @@ -0,0 +1,106 @@ +--- +title: Set.prototype.size +slug: Web/JavaScript/Referencia/Objetos_globales/Set/size +translation_of: Web/JavaScript/Reference/Global_Objects/Set/size +--- +
{{JSRef}}
+ +

La propiedad de acceso size devuelve el número de elementos que hay en el objeto {{jsxref("Set")}}.

+ +

Descripción

+ +

El valor de size es un entero que representa cuantas entradas tiene el objeto Set. La función de accesso set para size es undefined; no se puede cambiar esta propiedad.

+ +

Ejemplos

+ +

Usando size

+ +
var mySet = new Set();
+mySet.add(1);
+mySet.add(5);
+mySet.add("un texto")
+
+mySet.size; // 3
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstatusComentario
{{SpecName('ES6', '#sec-get-set.prototype.size', 'Set.prototype.size')}}{{Spec2('ES6')}}Definición inicial
{{SpecName('ESDraft', '#sec-get-set.prototype.size', 'Set.prototype.size')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidad de navegadores

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Soporte básico38{{ CompatGeckoDesktop("19") }} [1]{{ CompatIE("11") }}257.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatNo}}38{{CompatGeckoMobile("19")}}{{CompatNo}}{{CompatNo}}8
+
+ +

[1] From Gecko 13 (Firefox 13 / Thunderbird 13 / SeaMonkey 2.10) to Gecko 18 (Firefox 18 / Thunderbird 18 / SeaMonkey 2.15 / Firefox OS 1.0.1 / Firefox OS 1.1) la propiedad size fue implementado como un método Set.prototype.size(), esto fue cambiado a una propiedad en versiones posteriores conforme la especificación ECMAScript 6 (bug 807001).

+ +

Ver también

+ + diff --git a/files/es/web/javascript/reference/global_objects/set/values/index.html b/files/es/web/javascript/reference/global_objects/set/values/index.html new file mode 100644 index 0000000000..8b7ec88ece --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/set/values/index.html @@ -0,0 +1,72 @@ +--- +title: Set.prototype.values() +slug: Web/JavaScript/Referencia/Objetos_globales/Set/values +translation_of: Web/JavaScript/Reference/Global_Objects/Set/values +--- +
{{JSRef}}
+ +

El método values() retorna un objeto de tipo Iterator que contiene los valores para cada elemento en el objecto Set en orden de inserción.

+ +

El metodo keys() es un alias para este metodo (por similaridad con objetos {{jsxref("Map")}}); se comporta exactamente igual y retorna valores para cada elemento de un Set.

+ +
{{EmbedInteractiveExample("pages/js/set-prototype-values.html")}}
+ + + +

Syntax

+ +
mySet.values();
+
+ +

Return value

+ +

Un nuevo objeto Iterator que contiene los valores para cada elemento en el Set dado,  en orden de inserción.

+ +

Examples

+ +

Using values()

+ +
var mySet = new Set();
+mySet.add('foo');
+mySet.add('bar');
+mySet.add('baz');
+
+var setIter = mySet.values();
+
+console.log(setIter.next().value); // "foo"
+console.log(setIter.next().value); // "bar"
+console.log(setIter.next().value); // "baz"
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES2015', '#sec-set.prototype.values', 'Set.prototype.values')}}{{Spec2('ES2015')}}Initial definition.
{{SpecName('ESDraft', '#sec-set.prototype.values', 'Set.prototype.values')}}{{Spec2('ESDraft')}}
+ +

Browser compatibility

+ + + +

{{Compat("javascript.builtins.Set.values")}}

+ +

See also

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