I have a local storage as follows
Key0 is key and its value is {“fav1,fav2,fav3,fav4,fav5”}
If i use localstorage.removeitem(‘key0’), whole value is completely removed
How do i specifically remove fav1 or fav2 or such using removeitem function or is there any simple way to remove a specific part of local storage
There is no simple way of doing this since the value you store under a specific key is just a string. So, if you store
"fav1,fav2,fav3,fav4,fav5"under the keykey0, then this value is just a string like any other (e.g.foobar). If you want to change that string which is stored in localStorage, you have to 1) read it from localStorage, 2) change it manually, and then 3) store it back into localStorage under the same key.The way this is usually done is by using JSON serialization and deserialization: