Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 6-data-storage/02-localstorage/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ What's interesting about them is that the data survives a page refresh (for `ses

We already have cookies. Why additional objects?

- Unlike cookies, web storage objects are not sent to server with each request. Because of that, we can store much more. Most browsers allow at least 2 megabytes of data (or more) and have settings to configure that.
- Unlike cookies, web storage objects are not sent to server with each request. Because of that, we can store much more. Most modern browsers allow at least 5 megabytes of data (or more) and have settings to configure that.
- Also unlike cookies, the server can't manipulate storage objects via HTTP headers. Everything's done in JavaScript.
- The storage is bound to the origin (domain/protocol/port triplet). That is, different protocols or subdomains infer different storage objects, they can't access data from each other.

Both storage objects provide same methods and properties:
Both storage objects provide the same methods and properties:

- `setItem(key, value)` -- store key/value pair.
- `getItem(key)` -- get the value by key.
Expand Down Expand Up @@ -124,7 +124,7 @@ The latter works, because `Object.keys` only returns the keys that belong to the

Please note that both key and value must be strings.

If were any other type, like a number, or an object, it gets converted to string automatically:
If they were any other type, like a number, or an object, they would get converted to a string automatically:

```js run
localStorage.user = {name: "John"};
Expand Down Expand Up @@ -219,7 +219,7 @@ Modern browsers also support [Broadcast channel API](mdn:/api/Broadcast_Channel_

## Summary

Web storage objects `localStorage` and `sessionStorage` allow to store key/value in the browser.
Web storage objects `localStorage` and `sessionStorage` allow to store key/value pairs in the browser.

- Both `key` and `value` must be strings.
- The limit is 5mb+, depends on the browser.
Expand Down