Activity 1: Understanding LocalStorage
-
Task 1: Write a script to save a string value to localStorage and retrieve it. Log the retrieved value.
-
Task 2: Write a script to save an object to localStorage by converting it to a JSON string. Retrieve and parse the object, then log it.
Activity 2: Using LocalStorage
-
Task 3: Create a simple form that saves user input (e.g., name and email) to localStorage when submitted. Retrieve and display the saved data on page load.
-
Task 4: Write a script to remove an item from localStorage. Log the localStorage content before and after removal.
Activity 3: Understanding SessionStorage
-
Task 5: Write a script to save a string value to sessionStorage and retrieve it. Log the retrieved value.
-
Task 6: Write a script to save an object to sessionStorage by converting it to a JSON string. Retrieve and parse the object, then log it.
Activity 4: Using SessionStorage
-
Task 7: Create a simple form that saves user input (e.g., name and email) to sessionStorage when submitted. Retrieve and display the saved data on page load.
-
Task 8: Write a script to remove an item from sessionStorage. Log the sessionStorage content before and after removal.
Activity 5: Comparing LocalStorage and SessionStorage
-
Task 9: Write a function that accepts a key and a value, and saves the value to both localStorage and sessionStorage. Retrieve and log the values from both storage mechanisms.
-
Task 10: Write a function that clears all data from both localStorage and sessionStorage. Verify that both storages are empty.
-
LocalStorage Script: Write a script that saves, retrieves, and removes items from localStorage, and displays the saved data on page load.
-
SessionStorage Script: Create a script that saves, retrieves, and removes items from sessionStorage, and display
-
Storage Comparison Script: Write a script that saves data to both localStorage and sessionStorage, retrieves the data, and compares the results.
-
Clear Storage Script: Create a script that clears all data from both localStorage and sessionStorage, and verifies the operation.
By the end of these activities, you will:
-
Understand how to use localStorage and sessionStorage for persistent and session- specific data storage.
-
Save, retrieve, and remove data from both localStorage and sessionStorage.
-
Implement form data storage using localStorage and sessionStorage.
-
Compare and contrast the use cases for localStorage and sessionStorage.