Skip to content

Commit 00bfa6d

Browse files
authoredFeb 3, 2022
Merge pull request #2840 from ruslauz/fix/local-storage-spec-link
Fixes localStorage spec link
2 parents d92b1a0 + 5d832d9 commit 00bfa6d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎6-data-storage/02-localstorage/article.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ delete localStorage.test;
6464
That's allowed for historical reasons, and mostly works, but generally not recommended, because:
6565

6666
1. If the key is user-generated, it can be anything, like `length` or `toString`, or another built-in method of `localStorage`. In that case `getItem/setItem` work fine, while object-like access fails:
67+
6768
```js run
6869
let key = 'length';
6970
localStorage[key] = 5; // Error, can't assign length
@@ -119,7 +120,6 @@ for(let key of keys) {
119120

120121
The latter works, because `Object.keys` only returns the keys that belong to the object, ignoring the prototype.
121122

122-
123123
## Strings only
124124

125125
Please note that both key and value must be strings.
@@ -148,7 +148,6 @@ Also it is possible to stringify the whole storage object, e.g. for debugging pu
148148
alert( JSON.stringify(localStorage, null, 2) );
149149
```
150150

151-
152151
## sessionStorage
153152

154153
The `sessionStorage` object is used much less often than `localStorage`.
@@ -180,7 +179,7 @@ That's exactly because `sessionStorage` is bound not only to the origin, but als
180179
181180
## Storage event
182181
183-
When the data gets updated in `localStorage` or `sessionStorage`, [storage](https://www.w3.org/TR/webstorage/#the-storage-event) event triggers, with properties:
182+
When the data gets updated in `localStorage` or `sessionStorage`, [storage](https://html.spec.whatwg.org/multipage/webstorage.html#the-storageevent-interface) event triggers, with properties:
184183
185184
- `key` – the key that was changed (`null` if `.clear()` is called).
186185
- `oldValue` – the old value (`null` if the key is newly added).
@@ -221,6 +220,7 @@ Modern browsers also support [Broadcast channel API](mdn:/api/Broadcast_Channel_
221220
## Summary
222221
223222
Web storage objects `localStorage` and `sessionStorage` allow to store key/value in the browser.
223+
224224
- Both `key` and `value` must be strings.
225225
- The limit is 5mb+, depends on the browser.
226226
- They do not expire.

0 commit comments

Comments
 (0)
Failed to load comments.