In the Chrome console I set foo to null:
localStorage.setItem(\"foo\",null)
Then I test, whether it is null:
Please see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
All values are stored as strings in local storage. You should stringify data before storing it and parse data after retrieving it:
localStorage.setItem("foo", JSON.stringify(null));
var value = JSON.parse(localStorage.getItem("foo"));
console.log(value === null);