What's a better way to swap two argument values?
<p>So given a function</p>

<pre><code>function foo( a, b ) {

}
</code></pre>

<p>Now, if I wanted to swap the values of the arguments <code>a</code> and <code>b</code>, I could write this:</p>

<pre><code>var t = a;
a = b;
b = t;
</code></pre>

<p>However, this is an ugly pattern - it requires three statements (three lines of code), plus a local variable. Now, I could bear three statements, but having to declare that annoying helper variable? I would like to avoid that.</p>

<p>So, what would be a better way to do this? (Better as in fewer lines of code (possibly one-liner), or not declaring a local variable.)</p>

<p>I came up with this:</p>

<pre><code>(function ( t ) { a = b; b = t; })( a ); // swap a and b
</code></pre>

<p><strong>Live demo:</strong> <a href="http://jsfiddle.net/J9T22/" rel="nofollow">http://jsfiddle.net/J9T22/</a></p>

<p>So, what can you come up with?</p>
