Created
March 20, 2018 20:41
-
-
Save tab114/8bd55455b2b28317bd898f7e86d9ac46 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
| Storage.prototype.setObject = function(key, value) { | |
| this.setItem(key, JSON.stringify(value)); | |
| } | |
| Storage.prototype.getObject = function(key) { | |
| var value = this.getItem(key); | |
| return value && JSON.parse(value); //returns the | |
| } | |
| var userActionObject = "UserAction--TravelViewed", | |
| userActionShow = "showrecommendations", | |
| userActionHidden = "hiderecommendations", | |
| localStorageObject = localStorage.getObject(userActionObject); | |
| console.log("localStorageObject 1 is " + localStorageObject); | |
| localStorage.setObject(userActionObject, userActionShow); | |
| localStorageObject = localStorage.getObject(userActionObject); | |
| console.log("localStorageObject 2 is " + localStorageObject); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment