DEV Community

Discussion on: How to save data in localStorage using JavaScript

Collapse
 
natclark profile image
Nathan

Just want to tag on that not all browsers support localStorage:

if (typeof localStorage !== `undefined`) {
    // Interact with `localStorage` here
}
// Do not interact with `localStorage` here
Enter fullscreen mode Exit fullscreen mode