aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/atomics/sub/index.html
blob: cce9ae06c6885b0804b64466aa00da9239384b0a (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
85
86
---
title: Atomics.sub()
slug: Web/JavaScript/Reference/Global_Objects/Atomics/sub
tags:
  - Atomics
  - Java
  - Method
  - Shared Memory
translation_of: Web/JavaScript/Reference/Global_Objects/Atomics/sub
---
<div>{{JSRef}}</div>

<p>Die statische <code><strong>Atomics</strong></code><strong><code>.sub()</code></strong> Methode subtrahiert eine gegebenen Wert an einer gegebenen Position im Array und gibt den alten Wert zurück. Diese atomare Operation garantiert, dass keine andere Schreiboperation während der Operation durchgeführt werden kann.</p>

<div>{{EmbedInteractiveExample("pages/js/atomics-sub.html")}}</div>



<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">Atomics.add(typedArray, index, value)
</pre>

<h3 id="Parameter">Parameter</h3>

<dl>
 <dt><code>typedArray</code></dt>
 <dd>Ein geteiltes getrypted Integer Array. Eines von {{jsxref("Int8Array")}}, {{jsxref("Uint8Array")}}, {{jsxref("Int16Array")}}, {{jsxref("Uint16Array")}}, {{jsxref("Int32Array")}} oder {{jsxref("Uint32Array")}}.</dd>
 <dt><code>index</code></dt>
 <dd>Die Position in <code>typedArray</code>, zu der <code>value</code> subtrahiert wird.</dd>
 <dt><code>value</code></dt>
 <dd>Die Zahl, die subtrahiert werden soll.</dd>
</dl>

<h3 id="Return_value">Return value</h3>

<p>Der alte Wert an der gegebenen Position (<code>typedArray[index]</code>).</p>

<h3 id="Exceptions">Exceptions</h3>

<ul>
 <li>Erzeugt einen {{jsxref("TypeError")}}, wenn <code>typedArray</code> nicht von einem erlaubten Integer Typ ist.</li>
 <li>Erzeugt eine {{jsxref("TypeError")}}, wenn <code>typedArray</code> kein geteilter Arraytyp ist.</li>
 <li>Erzeugt ein {{jsxref("RangeError")}}, wenn der <code>index</code> nicht in den Grenzen von <code>typedArray</code> ist.</li>
</ul>

<h2 id="Beispiele">Beispiele</h2>

<pre class="brush: js">var sab = new SharedArrayBuffer(1024);
var ta = new Uint8Array(sab);
ta[0] = 48;

Atomics.sub(ta, 0, 12); // returns 48, the old value
Atomics.load(ta, 0); // 36</pre>

<h2 id="Spezifikationen">Spezifikationen</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-atomics.sub', 'Atomics.sub')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td>Initiale Definition in ES2017.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browserkompatibilität">Browserkompatibilität</h2>



<p>{{Compat("javascript.builtins.Atomics.sub")}}</p>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{jsxref("Atomics")}}</li>
 <li>{{jsxref("Atomics.add()")}}</li>
</ul>

<p> </p>