Function deleteFromLocalStorage

  • Deletes an item from the local storage.

    This function checks if the window object is defined and if localStorage is available. If both conditions are met, it removes the item associated with the specified key from the local storage.

    Parameters

    • key: string

      The key of the item to be removed from local storage.

    Returns void

    // Assuming local storage contains an item with key 'user'
    deleteFromLocalStorage('user');
    // The item with key 'user' is now removed from local storage