Storing boolean value in localStorage, this value is converted to string.
Now trying to converting back this value from localStorage to boolean, i need to use JSON.parse()
method, the more handy !!
doesn't work.
Code sample:
var test = false;
localStorage['test'] = test;
console.log("JSON.parse returns: ", JSON.parse(localStorage['test']), "expected: ", test);
console.log("'!!' returns: ", !! localStorage['test'], "expected: ", test);
I'm quite confused why this behaviour. Any explaination?
PS: using getter/setter localStorage methods doesn't matter here, same result.