El mètode has()
retorna un booleà que indica si l'element amb el valor especificat existeix o no dins l'objecte Set
.
Sintaxi
mySet.has(valor);
Paràmetres
- valor
- Obligatori. El valor a comprovar si pertany o no a l'objecte
Set
.
Valor retornat
- Booleà
- Retorna
true
si existex un element amb el valor especificat dins l'objecteSet
; en cas contrari retornafalse
.
Exemples
Utilitzar el mètode has
var mySet = new Set();
mySet.add("foo");
mySet.has("foo"); // retorna true
mySet.has("bar"); // retorna false
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Set.prototype.has' 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 | 13.0 (13.0) | 11 | 25 | 7.1 |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | No support | 38 | 13.0 (13.0) | No support | No support | 8 |