What exactly is Local Storage and how is it used?

Here's all you need to know:
The local storage is a mechanism used to store information about a user like his/her

- name
- interests
- preferences

or even cookie in the client's computer.

It is a small database controlled by the web browser
- You can only store the values as strings, not array or object

- If the information you want to store in local storage is an array, object or map, you must first coerce it to a string.

- Info will remain even after the tab is closed.
Let's assume a user inputs his/her name in a form, this function will be called to save the name in local storage:

function saveName(name) {
localStorage.setItem('name', name);
}
When that same user returns, you can retrieve the name from local storage and use it to log him/her in:

function getName(name) {
localStorage.getItem('name');
}
To remove that particular information (name) from local storage:

function getName(name) {
localStorage.removeItem('name');
}
If you are saving group of information about a user (eg, an Object), you must first "stringify" it:

function saveInformation(info) {
const infoString = JSON.stringify([...info]);
localStorage.setItem('information', infoString);
}
To clear all the information from local storage:

function clearInfo() {
localStorage.clear();
}
Local Storage is a simple yet handy mechanism for storing user information on the browser.

If you learned from this, be sure to follow me 👉 @UbahTheBuilder for more on JavaScript.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Kingsley Ubah

Kingsley Ubah Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @UbahTheBuilder

28 May
How to become a full-stack web developer in 2021

🧵
🔹Learn HTML

HTML is the markup language of the web. With it, you can make texts underlined, bold, italicized etc.

You can also create navigations, forms and many more web elements.

Learn about HTML here 👇

w3schools.com/html/
🔹Learn CSS

CSS (Cascading Style Sheets) is used to style/design HTML elements. Without CSS, the whole web page would look boring. CSS can also be used to create simple, yet eye-catching animations.

Learn more about CSS with (@traversymedia)

Read 14 tweets
26 May
7 essential skills every web developer should have (my opinion)

🧵
🔹 Problem Solving

I put this first because I think it's the most essential soft skill to posses

Whether you are planning your site's design, styling elements or debugging, you are solving a problem

Web devt and programming is all about problem solving and critical thinking.
🔹 Communication

Not everyone knows what the DOM, Git or an API is

Being able to communicate difficult concepts in a simple and digestible way is a crucial skill, especially for teamwork and collaboration

Mastering the art of effective communication is crucial for a web dev
Read 9 tweets
24 May
7 Popular CSS Selectors To Know

A thread 🧵
🔹Universal Selector

The universal selector matches all the elements in a HTML document

It is represented by an asterisk (*)

* {
...
}
🔹Type Selector

The type selector matches all the elements specified in a comma- delimited list.

It allows you specify the same styles to several elements

h1, h2, h3 {
...
}
Read 9 tweets
19 May
7 VSCode extensions to improve productivity as a web developer

Thread below 🧵
🔹LIVE SERVER

Live Server sets up a local development server with a live reload feature for previewing your site

Every time you save your code, you'll instantly see the changes on the browser

marketplace.visualstudio.com/items?itemName…
🔹ICON FONTS

Icon Fonts offers snippets for a variety of icon fonts, including the popular Font Awesome v5 icon pack.

marketplace.visualstudio.com/items?itemName…
Read 10 tweets
18 May
7 GitHub Repositories all web developers should know

Thread below 🧵
🔹33 JS CONCEPTS

This repository contains 33 concepts that every JavaScript developer should know. It is a very useful repository for both newbie and experienced JavaScript developers to strongly grasp the basics of JavaScript

github.com/leonardomso/33…
🔹 AWESOME CLEANSHEETS

Cleensheets are very useful resources which contains huge amount of information on a specific topic.
This repository has got cheatsheets for basically everything — from frontend libraries to backend and even databases.

github.com/LeCoupa/awesom…
Read 9 tweets
17 May
The quickest way to learn JavaScript is by having the right resources.

Here are some good resource to learn JavaScript.

🧵
🔹JavaScript Prototype - 🔗 freecodecamp.org/news/a-beginne…

🔹ES6 - 🔗 w3schools.com/js/js_es6.asp

🔹Variable Scoping - 🔗 w3schools.com/js/js_scope.asp

🔹JavaScript Closures - 🔗 developer.mozilla.org/en-US/docs/Web…
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(