blob: f0f4cf5f3e476e76180db96e3415d7ad2fc1eaa1 (
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
83
84
|
---
title: Set.prototype.delete()
slug: Web/JavaScript/Reference/Global_Objects/Set/delete
translation_of: Web/JavaScript/Reference/Global_Objects/Set/delete
---
<div>{{JSRef}}</div>
<p>Die <strong><code>delete()</code></strong> Methode entfernt das angegebene Element aus einem <code>Set</code> Objekt.</p>
<div>{{EmbedInteractiveExample("pages/js/set-prototype-delete.html")}}</div>
<div class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</div>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox notranslate"><var>mySet</var>.delete(<var>value</var>);</pre>
<h3 id="Parameter">Parameter</h3>
<dl>
<dt><code><var>value</var></code></dt>
<dd>Der zu entfernende Wert aus <code><var>mySet</var></code>.</dd>
</dl>
<h3 id="Rückgabewert">Rückgabewert</h3>
<p>Rückgabewert ist <code>true</code> wenn <code><var>value</var></code> erfolgreich aus <code><var>mySet entfernt wurde</var></code>; ansonsten<code>false</code>.</p>
<h2 id="Beispiel">Beispiel</h2>
<h3 id="Verwenden_der_delete_Methode">Verwenden der delete() Methode</h3>
<pre class="brush: js notranslate">const mySet = new Set();
mySet.add('foo');
mySet.delete('bar'); // Returns false. No "bar" element found to be deleted.
mySet.delete('foo'); // Returns true. Successfully removed.
mySet.has('foo'); // Returns false. The "foo" element is no longer present.
</pre>
<p>Ein Beispiel, wie ein Objekt aus einem Set entfernt werden kann.</p>
<pre class="brush: js notranslate">const setObj = new Set(); // Create a New Set.
setObj.add({x: 10, y: 20}); // Add object in the set.
setObj.add({x: 20, y: 30}); // Add object in the set.
// Delete any point with `x > 10`.
setObj.forEach(function(point){
if (point.x > 10){
setObj.delete(point)
}
})
</pre>
<h2 id="Spezifikationen">Spezifikationen</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('ESDraft', '#sec-set.prototype.delete', 'Set.prototype.delete')}}</td>
</tr>
</tbody>
</table>
<h2 id="Browserkompatibilität">Browserkompatibilität</h2>
<p>{{Compat("javascript.builtins.Set.delete")}}</p>
<h2 id="Siehe_auch">Siehe auch</h2>
<ul>
<li>{{jsxref("Set")}}</li>
<li>{{jsxref("Set.prototype.clear()")}}</li>
</ul>
|