title: Why is a boolean false parameter not interpreted when passing to a function?
body: <p>I did some research but I didn't find a satisfying answer yet. I have a javascript project file and a library where some functions are defined like this:</p>
  
  <pre><code>//Library.js 
  FElib = {
  
          initLib: function(param1, param2){
              var init = param1 || true;
              console.log(init);
          }
  }
  </code></pre>
  
  <p>Now in my project.js file I call the function and pass false as a parameter</p>
  
  <pre><code>FElib.initLib(false, 'test');
  </code></pre>
  
  <p>In this case param1 is giving me 'false' if I log it before the variable declaration. Afterwards it's using the default 'true'. It seems like it is interpreting false as undefined were I thought that it's only checking for undefined..</p>
  
  <p>Why is the behaviour like this?</p>
  
  <p>When I'm using a string it's perfectly working. Using 0 or 1 as a parameter is also not working and it's using the default variable declaration..</p>
  
  <p>As a workaround I declared the variable as an object which is workin fine again like so:</p>
  
  <pre><code>//Library.js
  FElib = {
  
          initLib: function(options){
              var defaults = {
                  param1:      true,
                  param2:      'string',
              };
              var options = $.extend({}, defaults, options);
          }
  }
  </code></pre>
  
  <p>Now calling the function is working fine even with boolean arguments:</p>
  
  <pre><code>FElib.initLib({'param1':false, 'param2':'string123'});
  </code></pre>
  
  <p>The 2nd approach seems to have a little overhead thinking of a function with only 1 boolean variable as an argument. </p>
  
  <p>Can anybody explain this behaviour?</p>