aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/weakset/has/index.md
blob: 92a8ffa9afb9396ee95dda4142bac58416a68ba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: WeakSet.prototype.has()
slug: Web/JavaScript/Reference/Global_Objects/WeakSet/has
tags:
  - ECMAScript 2015
  - JavaScript
  - Méthode
  - Prototype
  - Reference
  - WeakSet
translation_of: Web/JavaScript/Reference/Global_Objects/WeakSet/has
original_slug: Web/JavaScript/Reference/Objets_globaux/WeakSet/has
---
{{JSRef}}

La méthode **`has()`** renvoie un booléen indiquant si un objet donné est contenu dans l'ensemble` WeakSet`.

{{EmbedInteractiveExample("pages/js/weakset-prototype-has.html")}}

## Syntaxe

    ws.has(valeur);

### Paramètres

- `valeur`
  - : Ce paramètre est obligatoire. Il représente l'objet dont on souhaite savoir s'il est, ou non, présent dans l'objet `WeakSet`.

### Valeur renvoyée

- Booléen
  - : La méthode renvoie `true` si l'objet `WeakSet `contient bien un élément avec la valeur donnée, `false `sinon.

## Exemples

```js
var ws = new WeakSet();
var obj = {};
ws.add(window);

mySet.has(window);  // renvoie true
mySet.has(obj);     // renvoie false
```

## Spécifications

| Spécification                                                                                            | État                         | Commentaires         |
| -------------------------------------------------------------------------------------------------------- | ---------------------------- | -------------------- |
| {{SpecName('ES2015', '#sec-weakset.prototype.has', 'WeakSet.prototype.has')}} | {{Spec2('ES2015')}}     | Définition initiale. |
| {{SpecName('ESDraft', '#sec-weakset.prototype.has', 'WeakSet.prototype.has')}} | {{Spec2('ESDraft')}} |                      |

## Compatibilité des navigateurs

{{Compat("javascript.builtins.WeakSet.has")}}

## Voir aussi

- {{jsxref("WeakSet")}}
- {{jsxref("WeakSet.prototype.add()")}}
- {{jsxref("WeakSet.prototype.delete()")}}