aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/javascript/reference/global_objects/weakmap/has/index.html
blob: 8c751892356acd3ff8dca186b8ddc79a51bbce5d (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
---
title: WeakMap.prototype.has()
slug: Web/JavaScript/Reference/Global_Objects/WeakMap/has
translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/has
---
<div>{{JSRef}}</div>

<p>O método <code><strong>has()</strong></code> retorna um booleano indicando se um elemento com a chave especificada existe no objeto <code>WeakMap</code> ou não.</p>

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



<h2 id="Sintaxe">Sintaxe</h2>

<pre class="syntaxbox"><code><em>wm</em>.has(chave);</code></pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt>chave</dt>
 <dd>Obrigatório. A chave do elemento cuja presença deve ser verificada no objeto <code>WeakMap</code>.</dd>
</dl>

<h3 id="Valor_de_retorno">Valor de retorno</h3>

<dl>
 <dt>Boolean</dt>
 <dd>Retorna <code>true</code> se um elemento com a chave especificada existir no objeto <code>WeakMap</code>. Caso contrário, retorna <code>false</code>.</dd>
</dl>

<h2 id="Exemplos">Exemplos</h2>

<h3 id="Utilizando_o_método_has">Utilizando o método <code>has</code> </h3>

<pre class="brush: js">var wm = new WeakMap();
wm.set(window, 'foo');

wm.has(window); // retorna true
wm.has('baz');  // retorna false
</pre>

<h2 id="Especificações">Especificações</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES2015', '#sec-weakmap.prototype.has', 'WeakMap.prototype.has')}}</td>
   <td>{{Spec2('ES2015')}}</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-weakmap.prototype.has', 'WeakMap.prototype.has')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Compatibilidade com navegadores</h2>



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

<h2 id="Ver_também">Ver também</h2>

<ul>
 <li>{{jsxref("WeakMap")}}</li>
 <li>{{jsxref("WeakMap.prototype.set()")}}</li>
 <li>{{jsxref("WeakMap.prototype.get()")}}</li>
</ul>