title: Using localStorage as a nested dictionary
body: <p>I have seen the current solutions on stackoverflow such as:</p>
  
  <pre><code>Storage.prototype.setObject = function(key, value) {
      this.setItem(key, JSON.stringify(value));
  }
  
  Storage.prototype.getObject = function(key) {
      var value = this.getItem(key);
      return value &amp;&amp; JSON.parse(value);
  }
  </code></pre>
  
  <p>But I am trying to do something like:
  localStorage[a][b] = 5 with a function call localStorage.setItem('a', 'b', 5).</p>
  
  <p>I currently have a code that is not working because of referencing problems:</p>
  
  <pre><code>Storage.prototype.setVal = function(key, val) {
      var val = Array.prototype.pop.call(arguments);
      var cur_depth = this;
      for (var i in arguments) {
          var cur_key = arguments[i];
          cur_depth = JSON.parse(cur_depth[cur_key]);
      }
      cur_depth = JSON.stringify(val);
  }
  </code></pre>
  
  <p>And my last, even more hacky, attempt:</p>
  
  <pre><code>Storage.prototype.setVal = function(key, val) {
      var val = JSON.stringify(Array.prototype.pop.call(arguments));
      var keys = ''; // hacky eval solution
      for (var i in arguments) {
          var cur_key = arguments[i];
          keys += '["' + cur_key + '"]';
      }
      eval('this' + keys + '=' + val);
  }
  </code></pre>