Set.prototype.add()
Metoda add() dodaje nowy element o określonej wartości (value
) na koniec obieku Set
.
Składnia
mySet.add(value);
Parametry
- value
- Wymagany parametr. Wartość elementu, która zostanie dodana do obieku
Set
.
Zwracana wartość
Obiekt Set
.
Przykłady
Użycie metody add
var mySet = new Set();
mySet.add(1);
mySet.add(5).add('some text'); // można stworzyć "łańcuch"
console.log(mySet);
// Set [1, 5, "some text"]
Specyfikacje
Specyfikacja | Status | Komentarz |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Set.prototype.add' in that specification. |
Standard | Początkowa definicja |
ECMAScript (ECMA-262) The definition of 'Set.prototype.add' in that specification. |
Living Standard |
Kompatybilność przeglądarek
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! (en-US)
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 38 | (Yes) | 13.0 (13.0) | 11 | 25 | 7.1 |
Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | No support | 38 | (Yes) | 13.0 (13.0) | No support | No support | 8 |
Specyficzne zachowania w przeglądarkach
- W Firefox 33 (Firefox 33 / Thunderbird 33 / SeaMonkey 2.30) i wcześniejszych wersjach,
Set.prototype.add
zwracałundefined
i nie można było stworzyć "łańcucha". Błąd został naprawiony (błąd 1031632). Również w Chrome/v8 występuje ten problem.