Created
August 5, 2016 18:44
-
-
Save ramsunvtech/ff75f805fd5139d069da8a75f994ae17 to your computer and use it in GitHub Desktop.
Get all Storage Items
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.getItems = function () { | |
| var items = {}; | |
| for(var i=0; i < this.length; i++) { | |
| var itemKey = this.key(i), | |
| itemValue = this.getItem(itemKey); | |
| Object.defineProperty(items, itemKey, { | |
| value: itemValue | |
| }); | |
| } | |
| return items; | |
| }; | |
| // Usage | |
| localStorage.getItems(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment