I know you have a reason to learn javascript in particular, but I
recommend looking at CoffeeScript as well. It's the better javascript
:).

On Tue, Feb 21, 2012 at 5:13 PM, Edward K. Ream <[email protected]> wrote:
> I've got to learn javascript in order to read the MooTools sources :-)
>
> Some first steps.
>
> The MooTools sources are minimized, but not obfuscated.  Googling for
> "reformat JavaScript" took me to:
>
> http://jsbeautifier.org/
>
> I imported the result into Leo.  The importer needs more than a tad of
> work, but I was impatient, so I reformatted by hand.
>
> Semicolons confused me, so I googled "javascript semicolon".:
>
> http://mislav.uniqpath.com/2010/05/semicolons/
>
> So now some confusion has been eliminated.
>
> From within the above article, I found a link to "the module pattern",
>
> http://www.yuiblog.com/blog/2007/06/12/module-pattern/
>
> Here is an important excerpt:
>
> QQQ
> 2. Assign the return value of an anonymous function to your namespace
> object:
>
> YAHOO.myProject.myModule = function () {
>
>        return  {
>                myPublicProperty: "I'm accessible as
> YAHOO.myProject.myModule.myPublicProperty.",
>                myPublicMethod: function () {
>                        YAHOO.log("I'm accessible as
> YAHOO.myProject.myModule.myPublicMethod.");
>                }
>        };
>
> }(); // the parens here cause the anonymous function to execute and
> return
>
> Note the very last line with the closing curly brace and then the
> parentheses (). This notation causes the anonymous function to execute
> immediately, returning the object containing myPublicProperty and
> myPublicMethod. As soon as the anonymous function returns, that
> returned object is addressable as YAHOO.myProject.myModule.
> QQQ
>
> Ah.  Now I understand why the function can have no name, what similar
> code is doing, and why it *might* be a good idea to end the last line
> with a semicolon ;-)
>
> I'm still amazed that anyone can write software with a language like
> this, but now I have an inkling about how it might happen.
>
> Edward
>
> --
> You received this message because you are subscribed to the Google Groups 
> "leo-editor" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/leo-editor?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en.

Reply via email to