Categories
JavaScript Answers

How to detect if browser supports HTML5 Local Storage with JavaScript?

Spread the love

Sometimes, we want to detect if browser supports HTML5 Local Storage with JavaScript.

In this article, we’ll look at how to detect if browser supports HTML5 Local Storage with JavaScript.

How to detect if browser supports HTML5 Local Storage with JavaScript?

To detect if browser supports HTML5 Local Storage with JavaScript, we check if Storage is defined.

For instance, we write

if (typeof Storage !== "undefined") {
  // ...
} else {
  // ...
}

to check if Storage isn’t undefined with typeof Storage !== "undefined".

If it’s true, then local storage is available.

Otherwise, it’s not available.

Conclusion

To detect if browser supports HTML5 Local Storage with JavaScript, we check if Storage is defined.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.