title: Can I loop through 2 objects at the same time in JavaScript?
body: <p>related (sort of) to <a href="https://stackoverflow.com/questions/8504354/accessing-a-property-name-of-an-object">this</a> question. I have written a script that will loop through an object to search for a certain string in the referring URL. The object is as follows:</p>
  
  <pre><code>var searchProviders = {
    "google": "google.com",
    "bing": "bing.com",
    "msn": "search.msn",
    "yahoo": "yahoo.co",
    "mywebsearch": "mywebsearch.com",
    "aol": "search.aol.co",
    "baidu": "baidu.co",
    "yandex": "yandex.com"
  };
  </code></pre>
  
  <p>The <code>for..in</code> loop I have used to loop through this is:</p>
  
  <pre><code>for (var mc_u20 in mc_searchProviders &amp;&amp; mc_socialNetworks) { 
      if(!mc_searchProviders.hasOwnProperty(mc_u20)) {continue;}
      var mc_URL = mc_searchProviders[mc_u20];
      if (mc_refURL.search(mc_URL) != -1) {
          mc_trackerReport(mc_u20);
          return false;
      }
  </code></pre>
  
  <p>Now I have another object let's call it <code>socialNetworks</code> which has the following construct:</p>
  
  <pre><code>var socialNetworks = {"facebook" : "facebook.co" }
  </code></pre>
  
  <p>My question is, can I loop through both of these objects using just one function? the reason I ask is the variable <code>mc_u20</code> you can see is passed back to the <code>mc_trackerReport</code> function and what I need is for the <code>mc_u20</code> to either pass back a value from the <code>searchProviders</code> object or from the <code>socialNetworks</code> object. Is there a way that I can do this?</p>
  
  <p>EDIT: Apologies as this wasn't explained properly. What I am trying to do is, search the referring URL for a string contained within either of the 2 objects. So for example I'm doing something like:</p>
  
  <pre><code>var mc_refURL = document.referrer +'';
  </code></pre>
  
  <p>And then searching <code>mc_refURL</code> for one of the keys in the object, e.g. <code>"google.com"</code>, <code>"bing.com"</code> etc. 9this currently works (for just one object). The resulting <code>key</code> is then passed to another function. What I need to do is search through the second object too and return that value. Am I just overcomplicating things?</p>