Can anyone explain the for/in please?


#1



Hey, can anyone explain how the for/in works please?
Codeacadamy just kind of gives it to you without explaining exactly how it works.

Below is the for/in which they use for the contact list.
How does it know to search through the friends object and list the entries there?

var list = function(obj) {
  for(var prop in obj) {
    console.log(prop);
  }
};


Thanks


#2

google "mdn for in" ->
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in