To check whether a Storage item is set with JavaScript, we use the getItem
method.
For instance, we write
if (localStorage.getItem("infiniteScrollEnabled") === null) {
//...
}
to check if the local storage item with key 'infiniteScrollEnabled'
with the getItem
method.
If it’s null
, then the item with key 'infiniteScrollEnabled'
doesn’t exist in local storage.