Javascript: how to return own function?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6959426/can-a-javascript-function-return-itself">Can a JavaScript function return itself?</a>  </p>
</blockquote>



<p>Consider the following javascript function:</p>

<pre><code>var x = function(msg) {
    alert(msg);
    return x;
};

x('Hello')('World!');
</code></pre>

<p>This wil alert 'Hello' and 'World!'. Now I would like to rewrite the function without using a <code>var x</code> into something like:</p>

<pre><code>(function(msg)
{
    alert(msg);
    return this;
})('Hello')('World');
</code></pre>

<p>But this doesn't work. What am I doing wrong? How can I return my own function from the function?</p>
