Firefox Tomorrow

javascript instance method

Set.prototype.values()

View on MDN ↗

The values() method of Set instances returns a new set iterator object that contains the values for each element in this set in insertion order.

Interactive exampleOpen the canonical MDN source to run this embedded demo.
const set = new Set();
set.add(42);
set.add("forty two");

const iterator = set.values();

console.log(iterator.next().value);
// Expected output: 42

console.log(iterator.next().value);
// Expected output: "forty two"

Syntax

values()

Parameters

None.

Return value

A new iterable iterator object.

Examples

Using values()

const mySet = new Set();
mySet.add("foo");
mySet.add("bar");
mySet.add("baz");

const setIter = mySet.values();

console.log(setIter.next().value); // "foo"
console.log(setIter.next().value); // "bar"
console.log(setIter.next().value); // "baz"

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also