reading-notes


Project maintained by Razan-am Hosted on GitHub Pages — Theme by mattgraham

Local Storage

“The Past, Present, and Future of Local Storage for Web Applications”

A BRIEF HISTORY OF LOCAL STORAGE HACKS BEFORE HTML5

INTRODUCING HTML5 STORAGE

what is HTML5 Storage?

this data persists even after you navigate away from the web site, close your browser tab, exit your browser, or what have you.

USING HTML5 STORAGE

Like other JavaScript objects, you can treat the localStorage object as an associative array,instead of using the getItem() and setItem() methods, you can simply use square brackets`.

Example:

var foo = localStorage.getItem("bar");

localStorage.setItem("bar", foo);

…could be rewritten to use square bracket syntax instead:

var foo = localStorage["bar"];

localStorage["bar"] = foo;

Example:

interface Storage {

deleter void removeItem(in DOMString key);

void clear();

};

Calling removeItem() with a non-existent key will do nothing.

EXample:

interface Storage {

readonly attribute unsigned long length;

getter DOMString key(in unsigned long index);

};

If you call key() with an index that is not between 0–(length-1), the function will return null.

HTML5 STORAGE IN ACTION

References:

@ MMIX–MMXI Mark Pilgrim /Local Storage