Last active
August 29, 2015 14:16
-
-
Save wnstn/c5d9b44567812c7567fd to your computer and use it in GitHub Desktop.
LocalStorage Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OLD | |
function canUseLocalStorage() { | |
return typeof localStorage === 'object' && localStorage.setItem; | |
}; | |
// NEW | |
function canUseLocalStorage() { | |
var ls = "vox"; | |
try { | |
localStorage.setItem(ls, ls); | |
localStorage.removeItem(ls); | |
return true; | |
} catch(e) { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment