Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite+ 3
How to access local storage???
I wanted to make an for which I wanted to save some user data but there is no lesson in Sololearn which teaches how to access local storage I JavaScript. Can someone please help me ? I want some websites for reference. Any sample example will also do.
5 Réponses
+ 7
To store
localStorage.setItem(key, value);
To access:
localStorage.getItem(key);
To remove:
localStorage.remove(key)
+ 3
Also, to clear all:
localStorage.clear();
+ 3
Arjun Dawande
As you want to store users data in localStorage so here value will be users data and key will be each unique user for example.
There are 2 users Arjun and AJ so data will be store like:
localStorage.setItem('arjun', '1233')
localStorage.setItem('aj', '1233')
So now you can access each users data by using key 'arjun' or 'aj'
Remember value can be same but keys should be uniques.
+ 3
Thanks A͢J . I now understood it very well. 🙂
+ 2
Thank you A͢J & 🇮🇱 Radin Masiha 🇮🇱 for your answer but still I am not understanding what you meant by "key" and "value". Will you please explain me?