Last active
January 1, 2017 14:20
-
-
Save Loknar/99ac908f5999e51e6fe7b357d5ea3326 to your computer and use it in GitHub Desktop.
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
var localStorageWorks = function(debug) { | |
// simple test function to see if window.localStorage works | |
try { | |
window.localStorage.setItem("Test", "localStorageWorks"); | |
if (window.localStorage.getItem("Test") !== "localStorageWorks") { | |
throw new Error("localStorage seems to be broken"); | |
} | |
if (debug) { | |
console.log("localStorageWorks: returned positive") | |
} | |
return true; | |
} | |
catch (err) { | |
if (debug) { | |
console.warn("localStorageWorks: returned negative") | |
console.warn(err) | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment