What is Local Storage?
What can it be used for?
Local Storage can save information so that when a program is stopped you can get the data back. You can also use it for things like a log-in system.
How to Make a Key
A key is a thing that has data saved to it. Accessing the key will give you the data. To make a key and have data saved to it you will have something like this:
In this case, we are making a key called 'Key' and giving it a value of 'Value'. You are able to replace these with variables too.
How to Access a Key
Now if we have a value saved to a key we can access the value of the key.
const value = localStorage.getItem('Key');
The variable 'value' will now have the value 'Value' since of the key that we used. We can test this by printing it.
The output should say 'Value' or whatever you made the Value for the Key.
How to Delete a Key
Let's say that you made a key by accident or something else and you want to get rid of a key.
This will now delete the key from the database.
Local storage can only save 5MB of information
Information is only saved on Devices so if you save something on one device it will not be accessible on another
Altho Local Storage is easy to use it isn't very secure and shouldn't be used to save important information