On May 26, 12:41 pm, david <david.brill...@gmail.com> wrote:

> @ColinFine,
>
> > According to Flanagan's book (section 8.1.2) the optional function-
> > name in a function literal is not assigned to a variable, but
> > apparently lives in a special namespace of its own that allows the
> > function to refer to itself. So unless the function is recursive, the
> > above is identical to
>
> > var myFunction = function() {alert('hi');}
>
> > and more or less identical to
>
> > function myFunction() {alert('hi')}
>
> I try to refer to myFunction recursivelly and in both case it works
> (test done on FF3.0).
> could you send me an exemple of what you say ?

No I can't. I'm just quoting from the books.

> I'd only though the difference was in the scope of the created
> function depending on the way it is declare as a *statement* or as a
> *litteral*.
>
I didn't go into the reasons why Crockford advises not using function
statements. They are:
- "the second form makes it clear that [myFunction] is a variable
containing a function value. To use the language well, it is important
to understand that functions are values"
- "function statmenes are subject to 'hoisting'. This means that
regardless of where a function is placed, it is moved to the top of
the scope in which it is defined. ... It also prohibits the use of
function statements in if statements. ... "

It doesn't seem to me that these imply that there will be a different
scope, but I'm not sure.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to