Set.prototype.has()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
El método has()
retorna un booleano indicando si el elemento especificado existe en el objeto Set
o no.
Sintaxis
mySet.has(value);
Parametros
- valor
-
Requerido. El valor del cual se probará su presencia en el objeto
Set
.
Valor de retorno
- Booleano
-
Retorna
true
si el elemento con el valor especificado existe en el objetoSet
; de otra manera retornafalse
.
Ejemplos
Usando el método has
js
var mySet = new Set();
mySet.add("foo");
mySet.has("foo"); // retorna true
mySet.has("bar"); // retorna false
Especificaciones
Specification |
---|
ECMAScript® 2025 Language Specification # sec-set.prototype.has |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
has |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.