title: Javascript - Storing function in object - bad practice?
body: <p>Is it considered bad coding-practice to store functions in an object instead of just defining them (and therefore globally)?</p>
  
  <p>Consider:</p>
  
  <p>1.</p>
  
  <pre><code>Foo = {
      bar: function() {
          alert("baz");
      }   
  }
  </code></pre>
  
  <p><code>Foo.bar();</code></p>
  
  <p>vs.</p>
  
  <p>2.</p>
  
  <pre><code>function bar() {
      alert("baz");
  }
  </code></pre>
  
  <p><code>bar();</code></p>
  
  <p>Sure, it might be slightly less code for the second example, but when you start to get lots of functions - it will get messy.
  I find it way, way, cleaner to, for example, use <code>Game.update()</code> instead of using updateGame(); or similar. When getting deeper, like <code>Game.notify.admin(id)</code> and so on, it gives you even prettier code.</p>
  
  <p><strong>Is there any downsides by storing a function in an object?</strong></p>