I have an array of contacts in local storrage, and I need to remove, for example, the first element. How better to do? Is this expression correct?
localStorage.removeItem("allContacts"[0]);
I have an array of contacts in local storrage, and I need to remove, for example, the first element. How better to do? Is this expression correct?
localStorage.removeItem("allContacts"[0]);
localStorage contains string values. If you stringifyed an array and put it into localStorage, then you'll need to parse the array, delete the element you want, and then set the localStorage property again:
const allContacts = JSON.parse(localStorage.allContacts);
allContacts.shift();
localStorage.allContacts = JSON.stringify(allContacts);