this is possible because function(){} now is being evaluated as an expression
not a declaration
so function expressions are allowed to not have names.
On May 11, 2011, at 5:53 PM, gaz Heyes wrote:
> It's simply a function expression I think it's called, so it's actually
> illegal syntax just to have function(){} but if it becomes part of another
> statement then it works. You can't have a * or / first because it's illegal
> js syntax.
>
> This should be perfectly valid though:
> 123,
> function(){
> alert(1);
> }();
>
> On 11 May 2011 23:35, Jacob Beard <[email protected]> wrote:
> On Wed, May 11, 2011 at 6:21 PM, Nathan Sweet <[email protected]> wrote:
> > (someone
> > smarter than me will tell you why * and / don't work, but my guess is that
> > they don't coerce the same way as the operators listed above).
>
> I think that +, -, and ! can be unary or binary operators in js
> syntax, whereas * and / can only be binary operators. This makes sense
> when you think about their meaning in mathematics.
>
> Best,
>
> Jake
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]