reectrix
reectrix

Reputation: 8629

Do all browsers have local storage?

I wanted to know if it's necessary to do a check if local storage is present or not when I try to use it.

Ie, I have this as a check:

  if (global.localStorage) {
    global.localStorage.setItem('layout', JSON.stringify({
      [key]: value
    }));
  }

Or can I use localStorage without this check?

Upvotes: 11

Views: 14379

Answers (2)

user3746240
user3746240

Reputation: 341

You can see the full list of supported browsers here

Upvotes: 3

Alex S
Alex S

Reputation: 181

Mozilla maintain a table of desktop and mobile browser support here: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

enter image description here

Upvotes: 15

Related Questions