El mètode has()
retorna un booleà que indica si existeix un element amb la clau especificada o no.
Sintaxi
myMap.has(clau);
Paràmetres
- clau
- Obligatori. La clau de l'element que es comprovarà si existeix o no dins l'objecte
Map
.
Valor retornat
- Booleà
- Retorna
true
si existeix un element amb la clau proporcionada dins l'objecteMap
; retornafalse
en qualsevol altre cas.
Exemples
Utilitzar el mètode has
var myMap = new Map();
myMap.set("bar", "foo");
myMap.has("bar"); // retorn true
myMap.has("baz"); // retorn false
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Map.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 |