Possible Duplicate:
Chaining a function in JavaScript?
I asked a similar question, but a lot of people were confused and a lot of comments that made no sense (like someone commented jQuery overload... and this has nothing to do with jQuery).
So here's my question, how do I add to the HTML5 localStorage object and make a custom function called addItem()? It could be used like:
localStorage.getItem('names').addItem('Bill').getItem('names');
or
localStorage.getItem('names').addItem('Bill');
Last time people freaked out asking why I would do getItem twice. The first getItem would GET the items inside of names. There will always be something inside of names. addItem would add to names, then, getItem would return the names again, but Bill would be inside.
Now, it'd be also just as good for me for it to work like the second example. getItem would return the names, addItem would add Bill to the names and then RETURN all the names, including bill.
I could do setItem, which is part of the HTML5 API, but it's a pain:
var names = JSON.parse(localStorage.getItem("names"));
names.push("Bill");
localStorage.setItem("names", JSON.stringify(names));