This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
El mètode values()
retorna un nou objecte Iterator
que conté els valors per a cada element de l'objecte Set
en ordre d'inserció.
El mètode keys()
és un mètode sinònim d'aquest mètode (per a mantindre la similitud amb els objecte Map
); es comporta exactament de la mateixa forma i retorna els valors dels elements de l'objecte Set
.
Sintaxi
mySet.values();
mySet.keys();
Exemples
Utilitzar 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"
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Set.prototype.values' in that specification. |
Standard | Definició inicial. |
Compatibilitat amb navegadors
We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | 38 | 24 (24) | No support | 25 | 7.1 |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | No support | 38 | 24.0 (24) | No support | No support | 8 |