0
function loadChoice(key, varToStore) {
if (window.localStorage.getItem(key) === "true") {
    varToStore = true;
}
else if (window.localStorage.getItem(key) === "false") {
    varToStore = false;
}
else {
    varToStore = window.localStorage.getItem(key);
}

}

I think I found a way to pull booleans (that got converted to strings before) from the web-browser localstorage.

can anyone confirm or have a better method ?

  • Are the booleans in the local storage always stored as strings? Why arn't they booleans to start with? (just curious) – Arthur Putnam Aug 16 '16 at 16:54
  • With this setup `varToStore` will always be unchanged after calling `loadChoice`: [Is JavaScript a pass-by-reference or pass-by-value language?](https://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language) – Andreas Aug 16 '16 at 17:00

0 Answers0