I was wondering if its possible for localStorage to have a Boolean value instead of a string?
Using JS only no JSON if its impossible or can be done in JS a different way please let me know thanks
http://jsbin.com/qiratuloqa/1/
//How to set localStorage "test" to true?
test = localStorage.getItem("test");
localStorage.setItem("test", true);
if (test === true) {
alert("works");
} else {
alert("Broken");
}
/* String works fine.
test = localStorage.getItem("test");
localStorage.setItem("test", "hello");
if (test === "hello") {
alert("works");
} else {
alert("Broken");
}
*/
See Question&Answers more detail:os