Defining properties of a function
<p>Whilst reading the <a href="http://www.amazon.co.uk/JavaScript-Definitive-Guide-Activate-Guides/dp/0596805527" rel="nofollow">Javascript: The Definitive Guide</a> I was intrigued by the section <strong>Defining Your Own Function Properties</strong>. Let me give you an example:</p>

<pre><code>function foo( ) { 

    foo.bar++;

    return foo.bar;
};

foo.bar = 0;

foo( ); // returns 1
foo( ); // returns 2
</code></pre>

<p>So the above demonstrates how these properties can be used to persist data between multiple calls to a function. </p>

<p>I understand that properties are essentially public in the above example but is there any reason why this should not be used or why other methods of persisting data are preferred other than the obvious example of using closures to make properties private.</p>
