JSFiddle - React, Tailwind, and code Playground

by Martin MalĂ˝

JavaScript

sessionStorage.clear();
sessionStorage["testik"] ="sakra";
sessionStorage["bestik"] ="kakraholte";
sessionStorage["Westik"] ="haf";

// Here is Storage hack... ehm... expansion

function StorageIterator(storage){
  this.storage = storage;
  this.current = 0;
}
StorageIterator.prototype.next = function(){
  if (this.current == this.storage.length)
    throw StopIteration;
  else
  {
    var c = this.current++;
    return this.storage.key(c);
  }
};
    

Storage.prototype.__iterator__ = function(){
  return new StorageIterator(this);
};

//Storages are now iterable

for (var p in sessionStorage) {
    alert(p + ": "+sessionStorage[p]);
    }