For example, I have 2 arrays. One is myFavCars and one is myDislikedCars. How can I store them in local storage something like:
localStorage.setItem('myPreferences', { myFavCars: [], myDislikedCars: [] })
Is possible to store 2 different arrays in one item on local storage?
Yes you can with JSON.stringify to parse it to string, but then you will get a string you need to parse it back to Object.
localStorage.setItem('myPreferences',JSON.stringify({ myFavCars: [], myDislikedCars: []}))
And can read it with this:
const objt = JSON.parse(localStorage.getItem('myPreferences'))