localStorage.getItem
will return null
for keys that are unset:
The getItem(key) method must return the current value associated with the given key. If the given key does not exist in the list associated with the object then this method must return null.
Source: https://html.spec.whatwg.org/multipage/webstorage.html#dom-storage-getitem
2
solved What does the HTML5 Local Storage object return if there is no value? [closed]