title: Unable to iterate through JSON array
body: <p>I have a api (in NODEJS) response that gives back an array:</p>
  
  <pre><code>res.json(friends)
  [
      {
          "id": 7795239,
          "username": "janesmith"
      },
      {
          "id": 1363327,
          "username": "johnsmith"
      }
  ]
  </code></pre>
  
  <p>But when I want to iterate through the array before sending this response, I cannot find the way to do this.
  <code>users.length</code> does not exist, <code>for(var key users)</code> doens't work either.</p>
  
  <p>How to solve this?</p>
  
  <p>edit: the code where it gets the array:</p>
  
  <pre><code>User.find({}, function(err, users){
      if(err) res.send(err);
      var friends;
      var result = 'this will hold the result';
  
      for(var key in users){
          if(users[key].username == req.decoded.username) {
              friends = users[key].friends;
          }
      }
  
      // here I want to do things with the list of friends, so this is the place where I need to iterate over it
  
      res.json(result);
  });
  </code></pre>
  
  <p>This is the log result for <code>users</code> and <code>err</code></p>
  
  <pre><code>users: 
      [
          {
              "_id": "5710b02c7787794009325f62",
              "username": "demouser",
              "__v": 0,
              "friends": 
              [
                  {
                      "username": "janesmith",
                      "id": 7795239
                  },
                  {
                      "username": "johnsmith",
                      "id": 1363327
                  }
              ]
          }
      ]   
  err: null
  </code></pre>
  
  <p>This is the log of the keys:</p>
  
  <pre><code>toObject
  toJSON
  items
  db
  discriminators
  __v
  id
  _id
  friends
  password
  username
  userID
  schema
  collection
  comparePassword
  save
  $__delta
  $__version
  increment
  $__where
  remove
  model
  $__buildDoc
  init
  $__storeShard
  hook
  pre
  post
  removePre
  _lazySetupHooks
  update
  set
  $__shouldModify
  $__set
  getValue
  setValue
  get
  $__path
  markModified
  $__try
  modifiedPaths
  isModified
  isDirectModified
  isInit
  isSelected
  validate
  invalidate
  $__reset
  $__dirty
  $__setSchema
  $__registerHooks
  $__error
  $__doQueue
  $toObject
  inspect
  toString
  equals
  populate
  populated
  $__fullPath
  domain
  _events
  _maxListeners
  setMaxListeners
  getMaxListeners
  emit
  addListener
  on
  once
  removeListener
  removeAllListeners
  listeners
  listenerCount
  </code></pre>