From 50104c28ee8b79024733fad54f720e602314288a Mon Sep 17 00:00:00 2001 From: Osvaldo Dias dos Santos Date: Wed, 8 Mar 2023 22:27:26 +0100 Subject: [PATCH] Update "LocalStorage, sessionStorage" article --- 6-data-storage/02-localstorage/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/6-data-storage/02-localstorage/article.md b/6-data-storage/02-localstorage/article.md index 412f44c16..a99bcb653 100644 --- a/6-data-storage/02-localstorage/article.md +++ b/6-data-storage/02-localstorage/article.md @@ -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. @@ -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"}; @@ -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.