Deleting, changing localStorage [closed]

I often see on sites that if you delete or change some values from localStorage, they are restored to their original state after the site is reloaded. How is this done?

I tried to look for a solution on the Internet, but I couldn’t find anything.