Adding New Properties to a Function Object
<p>I am trying to understand the following pattern:</p>

<pre><code>// https://github.com/twitter/bootstrap/blob/master/js/bootstrap-collapse.js

  $.fn.collapse = function (option) {
    return this.each(function () {
      var $this = $(this)
        , data = $this.data('collapse')
        , options = typeof option == 'object' &amp;&amp; option
      if (!data) $this.data('collapse', (data = new Collapse(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  $.fn.collapse.defaults = {
    toggle: true
  }
</code></pre>

<p>It looks like <code>collapse</code> is a function object. Then, why <code>defaults</code> can be added as a property to <code>collapse</code>?</p>

<p>The following <a href="http://jsfiddle.net/sikusikucom/KTzUw/" rel="nofollow">(jsFiddle) snippet</a> tries to add a new property to a function object but to no avail. What is it?</p>

<pre><code>var my_object = function () {
    alert('Hello World!');
};
my_object.name = 'my_object';

console.log(my_object.name);  // prints an empty string
</code></pre>
