Skip to content

Instantly share code, notes, and snippets.

@ramsunvtech
Created August 5, 2016 18:44
Show Gist options
  • Select an option

  • Save ramsunvtech/ff75f805fd5139d069da8a75f994ae17 to your computer and use it in GitHub Desktop.

Select an option

Save ramsunvtech/ff75f805fd5139d069da8a75f994ae17 to your computer and use it in GitHub Desktop.
Get all Storage Items
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