You'll learn to love anonymous functions. And eventually, you'll even learn
to love closures:

(function($) {
  // do something
})(jQuery);

I guess cleanliness is relative. It looks pretty clean to me. The goal of
anonymous functions is to be able to pass around chunks of code to be
executed later. How would you propose a "cleaner" syntax look?

--Erik


On 9/26/07, A32 <[EMAIL PROTECTED]> wrote:
>
>
> I find the following example very dirty syntax:
>
> $(document).ready(function(){
>         alert("Document is ready")
>
>         $("a").click(function(){
>                 alert("Clicked");
>         });
> });
>
> With all those ) and } I don't know if I'm coming or going.. Is there
> an alternate syntax I can use? Do I *have* to use the "function()" all
> the time or is there a different way? I've been away from JavaScript
> for a long time but never seen anything like that :-)
>
> If there's no way around it, does anybody know of a javascript
> preprocessor that I could use a cleaner syntax while developing?
>
> Thanks!
>
>

Reply via email to