title: Javascript: can't access object property through for..in loop
body: <p>I am trying to access a property (name) on an object that is in fact located inside another object. I initialized the object in a file:</p>
  
  <pre><code>var icons = {
  
      "facebook": {name: 'facebook', icon_url: 'img/logos/facebook.png'}
  
  };
  </code></pre>
  
  <p>And then tried to check the object with this code:</p>
  
  <pre><code>   var icon_current_class;
  
    for(var icon in icons){
  
      console.dir(icon);
      //outputs an object named facebook but says it has no properties
  
      if( $(this).hasClass( icon.name ) ){
        icon_current_class = icon.name;
      }else{
        alert("Something went wrong. Please contact the mods.");
      }
    }
  </code></pre>
  
  <p>And of course, the alert("Something went wrong") goes off everytime I run this. I have tried for a long time to find a solution, but to no avail. Can anyone please help?</p>