title: Javascript compare value in object
body: <p>The deepEqual function is supposed to take in 2 values in see if they are exactly the same. The results for the first and second test come back as expected. Is there perhaps something wrong with the way I'm incorporating the recursive call?</p>
  
  <pre><code>function deepEqual(obj1, obj2) {
    if (typeof obj1 == 'object' &amp;&amp; typeof obj1 !== null &amp;&amp; typeof obj2 == 'object' &amp;&amp; typeof obj2 !== null) {
      if (obj1.length != obj2.length) {return false;}
      for (var prop in obj1) {
        if (typeof obj1[prop] == 'object') {deepEqual(obj1[prop], obj2[prop]);}
        if (obj1[prop] != obj2[prop]) {return false;}
      }
      return true;
    } else if (obj1 === obj2) {return true;}
    else {return false;}
  }
  
  var obj = {here: {is: "an"}, object: 2};
  console.log(deepEqual(obj, obj));
  // → true -&gt; true
  console.log(deepEqual(obj, {here: 1, object: 2}));
  // → false -&gt; false
  console.log(deepEqual(obj, {here: {is: "an"}, object: 2}));
  // → true -&gt; false
  </code></pre>