Es gibt mehrere Methoden zur Überprüfung, die ich hier anfüge
Methode 1
if("infiniteScrollEnabled" in localStorage){
console.log("Item exists in localstorage");
}else{
console.log("Item does not exist in localstoarge";
}
Methode 2
if(localStorage.getItem("infiniteScrollEnabled") === null){
console.log("Item does not exist in localstoarge";
}else{
console.log("Item exists in localstorage");
}
Methode 3
if(typeof localStorage["cart"] === "undefined"){
console.log("Item does not exist in localstoarge";
}else{
console.log("Item exists in localstorage");
}
Methode 4
if(localStorage.hasOwnProperty("infiniteScrollEnabled")){
console.log("Item exists in localstorage");
}else{
console.log("Item does not exist in localstoarge";
}