i am a newbie to HTML5.
I am reading head first HTML5 programming.
Here in a chapter it's mentioned that We are grabbing the array out of localStorage
.
function init() {
// button code here...
var stickiesArray = localStorage["stickiesArray"];
if (!stickiesArray) {
stickiesArray = [];
localStorage.setItem("stickiesArray", stickiesArray);
}
for (var i = 0; i < stickiesArray.length; i++) {
var key = stickiesArray[i];
var value = localStorage[key];
addStickyToDOM(value);
}
}
I didn't understand this line
var stickiesArray = localStorage["stickiesArray"];
We are grabbing StickiesArray out of Localstorage.
But should not there be a dot between them like
var stickiesArray = localStorage.stickiesArray;
to grab the items from localstorage??
Thanks.