What does this function do in Facebook's JavaScript source?
<p>I was reading some of Facebook's JavaScript, and came across a curious function that I couldn't figure out the purpose of:</p>

<pre><code>function bagof(a) {
    return function () {
        return a;
    };
}
</code></pre>

<p><em>As far as I can tell</em>: </p>

<ul>
<li><code>bagof</code> is a function that accepts the parameter <code>a</code>. </li>
<li><code>bagof</code> immediately returns an anonymous function. </li>
<li>The returned function then returns the original parameter <code>a</code>.</li>
</ul>

<p>I would assume that the usage of <code>bagof</code> would be something like this:</p>

<pre><code>newFunction = bagof("This is the data");
​console.log( newFunction() );​ //Logs "This is the data"​​​​​​​​​​​​
</code></pre>

<p>What's the point? Why not directly use or store whatever variable or function that was passed into <code>a</code>?</p>

<p><a href="http://jsbin.com/upuken/edit#javascript" rel="nofollow">The source file</a> looks like it contains many utility functions for the application.</p>
