In order to get access to the local storage in javascript, you can use the localStorage
object provided by the browser.
To set an item in the local storage, you can use the setItem
method of the localStorage
object as follows:
index.tsx38 chars2 lines
To retrieve the value of an item from the local storage, you can use the getItem
method of the localStorage
object as follows:
index.tsx43 chars2 lines
You can also remove an item from the local storage using the removeItem
method of the localStorage
object as follows:
index.tsx32 chars2 lines
And finally, you can clear the entire local storage using the clear
method of the localStorage
object as follows:
index.tsx22 chars2 lines
gistlibby LogSnag