title: Simple javascript line behaving differently in chrome and firefox
body: <p>I need to constantly check for modifications on a page MainContainer dimensions and when that happens I'll fix its dimensions to be bigger than the biggest element inside it (wraps all elements).</p>
  
  <p>If there are other ways of doing it is not really my concern. What is bothering me is the effect of changing one line.</p>
  
  <p>My code is:</p>
  
  <pre><code>var pageMaxWidth = 0;
  var pageMaxHeight = 0;
  (function fixWidth()
  {
   var intervalCounter = 0;
      var interval = setInterval(function(){
          var intervalMaxWidth = 0;
          var intervalMaxHeight = 0;
          $("#MainContainer table").each(function(index,elem){
              if($(elem).width()&gt;intervalMaxWidth)
              {
                  intervalMaxWidth=$(elem).width();
                  //console.debug("new interval width");
              }
              if($(elem).height()&gt;intervalMaxHeight)
              {
                  intervalMaxHeight=$(elem).height();
                  //console.debug("new interval height");             
              }
          });
          if(pageMaxWidth!=intervalMaxWidth)//I'm the referred if
          {
              $("#MainContainer").width(intervalMaxWidth);
              pageMaxWidth=intervalMaxWidth;
              console.debug("width fixed");
          }
          if(pageMaxHeight!=intervalMaxHeight)
          {
              $("#MainContainer").height(intervalMaxHeight);
              pageMaxHeight=intervalMaxHeight;
              console.debug("height fixed");
          }
          },500);
  })();
  </code></pre>
  
  <p>If on the commented if (I'm the referred if) I change:</p>
  
  <pre><code>$("#MainContainer").width(intervalMaxWidth);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>$("#MainContainer").width(intervalMaxWidth+40);
  </code></pre>
  
  <p>and run the script in Chrome it will always increment the MainContainer width, meaning it will always evaluate to true<code>pageMaxWidth!=intervalMaxWidth</code>. How can that happen if I didn't change the intervalMaxWidth value? But it is actually added 40 because I checked by debugging through the console.
  In FireFox that doesn't happen</p>