- localStorage.setItem() is used to set the value in a local storage variable.
- localStorage.getItem() is used to get the value of the variable stored on the local storage.
If you notice the above example then you know that I have set the value “My name is XYZ” in the first parameter of the setItem() method. On the other hand, I have used this parameter in the getItem() method to get the value of that variable.
Conclusion:- I hope this tutorial will help you to understand the overview. If there is any doubt then please leave a comment below.