delete localstorage key code example

Example 1: localstorage clear item

localStorage.removeItem(key);

Example 2: javascript localStorage clear items

localStorage.clear();//this clears the localStorage completely

Example 3: localstorage drop item

storage.removeItem(keyName);

Example 4: localstorage.removeitem()

// Don't use removeItem() that as the name says removes the whole item from localStorage. Just do another setItem() to overwrite the old data.
questions.splice(index, 1);
localStorage.setItem('questions',JSON.stringify(questions));