Introducing LocalStorage

For the storage, we use local storage to store the book list persistently.

The local storage uses key value pairing.

1// save a string.
2localStorage.setItem(key, value);
4// load a string.
7// remove an item.

LocalStorage uses string only for both keys and values. (Except Chrome)

Some browsers allow us to use the array notation to get/set local storage.

1localStorage["key here"] = "value goes here"; // set the value
3localStorage["key here"]; // get the value

But storing string is not quite useful. Next, we will see how we store objects.

What’s next? We’re going to take a look at “Converting objects into JSON string”.

overlaied image when clicked on thumbnail

Makzan | Mobile web app dev with phonegap | Table of Content