What I have learned about Local Storage:
Before we had local storage functionality from JavaScript, the only way to store information on the client browser was with cookies. Cookies had a very limited size of 4093 bytes per domain, so we couldn't store much. Now we can use local storage to store objects, data and arrays in the browser. With Chrome that can be up to 5mb.
To save objects in local storage we cast the JavaScript object into a JSON string using the JSON.stringify function. Then we can turn the string back into an object with the JSON parse function.
//example of a JSON.parse function
var jsonString = '{ "name":"Martha", "profession":"Student", "age":43}';
var jsonObject = JSON.parse(jsonString);
document.write("Hi, my name is " + jsonObject.name + ".");
document.write("I am " + jsonObject.age + "years old, and I'm a " + jsonObject.profession + ".");
Following is a small application that creates objects and adds them to a list, storing the information within the brower.
List of things to do:
(Click on item to remove from list)
Here are several examples of JavaScript functions that create and save strings, arrays and objects to local storage.