Jquery in 30 days inquiry
<p>I am currently watching a tutorial video "30 days to learn jQuery".
I have a question about why the tutor in the video <strong>returned a variable</strong> from a function.</p>

<p>Here's the code:</p>

<p>This is in the HTML file which just binds an event handler to buttons, calls functions, etc.</p>

<pre><code>(function() {

    slider.nav.find('button').on('click', function() {
        slider.setCurrent( $(this).data('dir') );
        slider.transition();
    });     
})();
</code></pre>

<p>and this is the one function I'm interested in (in the js file):</p>

<pre><code>Slider.prototype.setCurrent = function( dir ) {
    var pos = this.current;

    pos += ( ~~( dir === 'next' ) || -1 );
    this.current = ( pos &lt; 0 ) ? this.imgsLen - 1 : pos % this.imgsLen;

    return pos; // &lt;== HERE

};
</code></pre>

<p>The only thing I want to figure out is why <code>return pos</code>? I tried removing it and the code still worked.</p>

<p>Was it a mistake or is there sound logic to this?</p>

<p>In a nutshell, <code>setCurrent</code> function is called and <code>setCurrent</code> returns a value. But why?</p>
