Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Andrew Lim
3,724 PointsIn JavaScript why do you place brackets on some function calls and not others? When should you do this?
I just finished the jQuery basic lesson for the form passwords and noticed when some functions were called it used a bracket at the end and other times it did not.
e.g. isPasswordValid() <--bracket $password.focus(passwordEvent) <-- no bracket
Why is this? When should you use each?
Thanks :)
2 Answers

Aaron Loften
12,864 PointsThats a weird but valid way to write some functions. Conditional statements can be written that way too. I know, it irks me as well. It use to be my old boss' preferred way of doing it.

Andrew Lim
3,724 PointsThanks Liam.
So using brackets calls a function right away, but without means at some point in future reference this function?
liam johnshon
Courses Plus Student 904 Pointsliam johnshon
Courses Plus Student 904 Pointscalling function without brackets mean you are passing just a reference to a function & calling function with brackets means you are calling a function not passing a reference....!
suppose you have a function which is responsible for making alert on browser