I think a lot of the redundancy here comes from javascripts multiple inheritance from a lot of other languages.  The first two ways are the same as far as I'm aware and are vestiges of Java's "EverythingIsAnObject" syndrome.  In another sense, they are the underlying form of the last two because they are syntactically the simplest: they don't add any syntax to the language.
<br><br>The other two are syntactic sugar and very sweet at that.<br><br><span style="font-family: verdana;">var baz = function() {}</span> is technically a first class function sometimes referred to as a closure (although I prefer to use that term to refer to the act of enclosing other variables inside of it).&nbsp; In javascript jargon I think this is most commonly referred to as an anonymous function.&nbsp; As you are using it here, it&#39;s not really anonymous, you&#39;ve just split the process of creating and naming the function into two pieces.&nbsp; However, this syntax is great for something like this: 
<br><br><span style="font-family: verdana;">document.addEventListener(&quot;mousedown&quot;, function(event) { doSomething(event) }, false);</span><br><br>in which case you do have a truly anonymous function (even though its mostly a dummy wrapper for doSomething).
<br><br>The last form of course is the standard function creation form and it just simplifies the anonymous form so that creation and naming happen together.&nbsp; It saves you typing and is more familiar to people who&#39;ve never worked in a language that allows you to pass around functions like any other value (unfortunately, there&#39;s more that don&#39;t than do).
<br><br>Does that answer your question?<br><br>Rob<br><br><div><span class="gmail_quote">On 10/4/07, <b class="gmail_sendername">JS Student</b> &lt;<a href="mailto:tuofamerikazmostwanted@gmail.com">tuofamerikazmostwanted@gmail.com
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">These are the various methods to create functions in JavaScript:<br><br>
var foo = new Function();<br>var bar = Function();<br>var baz = function() {}<br>function zag() {}<br><br>My question is why there so many ways to do one task? Do these methods<br>serve some specific purpose or is it just redundancy?
<br><br>Thanks<br>_______________________________________________<br>Javascript mailing list<br><a href="mailto:Javascript@lists.evolt.org">Javascript@lists.evolt.org</a><br><a href="http://lists.evolt.org/mailman/listinfo/javascript">
http://lists.evolt.org/mailman/listinfo/javascript</a><br></blockquote></div><br>