How to Use Local Storage with JavaScript? 1

How to Use Local Storage with JavaScript?

const Car = {
  brand:"Suzuki",
  color:"white",
  price:10000
}

window.localStorage.setItem('car', JSON.stringify(Car));

Here is what the above code is Doing:
1. We created an object called Car.
2. We used the JSON.stringify() method to convert the object into a string.
3. We used the localStorage.setItem() method to save the stringified object into localStorage.

Similar Posts