StoreJS Example

How to usage of store.js

by secretgspot

HTML

<script src="http://alekse.searchrev.com/js/libs/storeJson2.min.js"></script>

JavaScript

// "Hey store.js, could you remember something for me?"
// "Sure, just give it a name so you can ask me later."
var name = "doc",
  string = 
    "A useful URL that I have a hard time remembering: "+
    "http://developer.mozilla.org";
store.set( name, string );

// ... later:
// "Hey store.js, what was this "doc" string, again?"
alert( store.get( "doc" ) );

// "Hey store.js, I've got this object literal and…"
// "I can handle that too!"
var name = "obj",
  object = {
    title: "Mr",
    firstName: "John",
    lastName: "Doe",
    emails: [
      "[email protected]",
      "[email protected]"
    ]
  };
store.set( name, object );

// Oh, and it's possible to remove some or all items
//store.remove( name );
//store.clear();
document.write( JSON.stringify(store.get( "obj" )) );
alert( store.get( "obj" ).emails );