Created
December 13, 2016 03:39
-
-
Save soggybag/f846029e2b555300dfbe7359f4340865 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Local storage | |
// Create an object | |
var obj = {name:"Joe", age:33, shoesize:9.5, favoriteFoods:["Apples", "Bananas"]}; | |
// Convert object to JSON string | |
var objJSON = JSON.stringify(obj); | |
// save JSON string to local storage with the key obj. | |
localStorage.setItem("obj", objJSON); | |
// Retrieve data from localstorage | |
var storedObjJSON = localStorage.getItem("obj"); | |
// Convert JSON string to JS Obj | |
var newObj = JSON.parse(storedObjJSON); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment