Difference Between }); and };?


#1

I've always wondered what the difference between }); and }; . It seems to have a pretty big impact on how Java code funtions, and I just can't put my finger on what makes them different. Any one else know the answer?


#2

Hey Wizbiz11211,

Everything that gets opened needs to be closed. So,

                           /* ↓ opening parenthesis */
   $('element').jqueryFunction(function() {
                                        /* ↑ opening curly brace */
   });
/* ↑ closing the curly brace and parenthesis */

It's important that you close something holding something else after you close the something else (if that makes sense?). So, this won't work:

)};

because you need to close them in the right order.

I hope this helps! :)


Java is to JavaScript as car is to carpet - they're completely different :wink:


#3

NOW I get it, I keep forgeting that there is an opening parenthesis before the function is called, but seeing that now i can understand where i went wrong. Thanks a bunch!

Also, I never knew Java and JavaScript were two different things. Guess I got some more to learn.