Possible duplicate:
Function chain in JavaScript?
I asked a similar question , but many people were confused and had a lot of comments that made no sense (for example, someone commented on jQuery overload ... and this has nothing to do with jQuery).
So here is my question: how to add an HTML5 localStorage object and create a custom addItem () function? It can be used as:
localStorage.getItem('names').addItem('Bill').getItem('names');
or
localStorage.getItem('names').addItem('Bill');
The last time people got scared, asking why I would do getItem twice. The first getItem should GET the elements inside the names. There will always be something in the names. addItem will add to the names, then getItem will return the names again, but Bill will be inside.
, . getItem , addItem , , .
setItem, API HTML5, :
var names = JSON.parse(localStorage.getItem("names"));
names.push("Bill");
localStorage.setItem("names", JSON.stringify(names));