How do you store Objects in localStorage?

I know how to store numbers, strings, booleans, and arrays in localStorage, but I don’t exactly know how to store Objects.

One Time, I tried, but the only value that was returned was ‘null’.
If you know how, please tell me how to.
Thanks.

You can’t store objects directly into localStorage, only strings. So you would have to ‘stringify’ the object first.

2 Likes

Thanks a lot. That was very useful info.