aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/api/storage/length/index.html
blob: 767ef0c21b3964d0015c7d021b04b3ba9ad3341f (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
---
title: Storage.length
slug: Web/API/Storage/length
tags:
  - API Eigenschaft Storage
translation_of: Web/API/Storage/length
---
<p>{{APIRef("Web Storage API")}}</p>

<p>Die <code>length</code>-Eigenschaft der {{domxref("Storage")}}-Schnittstelle enthält die Anzahl der im <code>Storage</code>-Objekt gespeicherten Datensätze.</p>

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

<pre class="syntaxbox">var <em>aLength</em> = <em>Storage</em>.length;</pre>

<h3 id="Rückgabewert">Rückgabewert</h3>

<p>Ein Integer.</p>

<h2 id="Beispiel">Beispiel</h2>

<p>Die folgende Funktion fügt drei Datensätze hinzu und liest abschließend die Anzahl der vorhandenen Datensätze:</p>

<pre class="brush: js">function populateStorage() {
  localStorage.setItem('bgcolor', 'yellow');
  localStorage.setItem('font', 'Helvetica');
  localStorage.setItem('image', 'cats.png');

  localStorage.length; // sollte 3 zurückgeben
}</pre>

<div class="note">
<p><strong>Hinweis</strong>: Weitere Beispiele sind im <a href="https://mdn.github.io/dom-examples/web-storage/">Web-Storage-Demo</a> zu finden.</p>
</div>

<h2 id="Spezifikation">Spezifikation</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('HTML WHATWG', 'webstorage.html#dom-storage-length', 'Storage.length')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

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



<p>{{Compat("api.Storage.length")}}</p>

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

<ul>
 <li><a href="/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API">Using the Web Storage API</a></li>
</ul>