I used to believe that there is no difference between them but after seeing this piece of code, all my information about objects in Javascript failed.
var search = function(name) {
  for(var x in friends) {
    if(friends[x].firstName === name) {
      console.log(friends[x]);
      return friends[x];
    }
  }
};
This code works. But
var search = function(name) {
  for(var x in friends) {
    if(friends.x.firstName === name) {
      console.log(friends.x);
      return friends.x;
    }
  }
};
this doesn't.
Thanks for explaining.
 
     
     
    