title: How to get only one element from an array (firebase database, nodejs)
body: <p>If I use <code>limitToLast(1)</code>, then I still get an object, with one key-value pair. To get the value, I use this code:</p>
  
  <pre><code>db.ref('/myarray').limitToLast(1).once('value').then(function(snapshot) {
  
      var result = snapshot.val();
      var lastElem;
      var lastKey;
  
      for(var i in result) {
          lastElem= result[i];
          lastKey = i;
          break;
      }
  
      ...
  
  });
  </code></pre>
  
  <p>It works, but I think I do it wrong. But haven't found any better solution in the docs. How should I load only one element?</p>
  
  <p>The database looks like this:
  <a href="https://i.stack.imgur.com/K26iJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K26iJ.png" alt="array"></a></p>