In the Chrome console I set foo to null:
localStorage.setItem(\"foo\",null)
Then I test, whether it is null:
As per spec, localstorage uses Storage object interface
interface Storage {
readonly attribute unsigned long length;
DOMString? key(unsigned long index);
getter DOMString? getItem(DOMString key);
setter void setItem(DOMString key, DOMString value); //notice this line
deleter void removeItem(DOMString key);
void clear();
};
setter method translates to setItem, accepts only DOMString
As per documentation
DOMString is a UTF-16 String. As JavaScript already uses such strings, DOMString is mapped directly to a String.
Passing null to a method or parameter accepting a DOMString typically stringifies to "null".