title: Navigating to previous and next item in a Javascript object
body: <p>I want to navigate up and down an JavaScript Object given an item of an object. An example object:</p>
  
  <pre><code>var items = {
     "5" : ["name", "link2"],
     "8" : ["name 2", "link 2"],
     "11" : ["name 3", "link 3"]
  }
  </code></pre>
  
  <p>Now, given I have the item <code>items["8"]</code>. I want to get previous and next item respectively.</p>
  
  <pre><code>getItemBefore = function(index) {
      // index holds 8
      // should return "5"
  }
  
  getItemAfter = function(index) {
      // index hold 8
      // should return 11
  }
  </code></pre>
  
  <p>How can I get those items?</p>