aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/weakset/has/index.html
blob: be5147bca46fef979063de38c7b7e734fda3519f (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
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
---
<div>{{JSRef}}</div>

<p>La méthode <code><strong>has()</strong></code> renvoie un booléen indiquant si un objet donné est contenu dans l'ensemble<code> WeakSet</code>.</p>

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

<p class="hidden">Le code source de cet exemple interactif est disponible dans un dépôt GitHub. Si vous souhaitez contribuez à ces exemples, n'hésitez pas à cloner <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> et à envoyer une <em>pull request</em> !</p>

<h2 id="Syntaxe">Syntaxe</h2>

<pre class="syntaxbox"><var>ws</var>.has(<var>valeur</var>);</pre>

<h3 id="Paramètres">Paramètres</h3>

<dl>
 <dt><code>valeur</code></dt>
 <dd>Ce paramètre est obligatoire. Il représente l'objet dont on souhaite savoir s'il est, ou non, présent dans l'objet <code>WeakSet</code>.</dd>
</dl>

<h3 id="Valeur_renvoyée">Valeur renvoyée</h3>

<dl>
 <dt>Booléen</dt>
 <dd>La méthode renvoie <code>true</code> si l'objet <code>WeakSet </code>contient bien un élément avec la valeur donnée, <code>false </code>sinon.</dd>
</dl>

<h2 id="Exemples">Exemples</h2>

<pre class="brush: js">var ws = new WeakSet();
var obj = {};
ws.add(window);

mySet.has(window);  // renvoie true
mySet.has(obj);     // renvoie false
</pre>

<h2 id="Spécifications">Spécifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spécification</th>
   <th scope="col">État</th>
   <th scope="col">Commentaires</th>
  </tr>
  <tr>
   <td>{{SpecName('ES2015', '#sec-weakset.prototype.has', 'WeakSet.prototype.has')}}</td>
   <td>{{Spec2('ES2015')}}</td>
   <td>Définition initiale.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-weakset.prototype.has', 'WeakSet.prototype.has')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>

<p>{{Compat("javascript.builtins.WeakSet.has")}}</p>

<h2 id="Voir_aussi">Voir aussi</h2>

<ul>
 <li>{{jsxref("WeakSet")}}</li>
 <li>{{jsxref("WeakSet.prototype.add()")}}</li>
 <li>{{jsxref("WeakSet.prototype.delete()")}}</li>
</ul>