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

JavaScript JavaScript Basics (Retired) Working With Numbers The Math Object

Mark Bernard
Mark Bernard
2,746 Points

empty brackets

Not a question directly related to the immediate topic of math functions, however it has cropped up a number of times where the brackets are used, and are left empty, for example in this video in the console the function of clear() is used. What is the purpose, precisely of the empty brackets, is it to indicate that, that function is applied to the entirety of the statement?

1 Answer

andren
andren
28,558 Points

Those round brackets (usually referred to as parenthesis in programming) is used to tell JavaScript that you want to call the function, and is needed regardless of whether you are passing the function any value. If you type the name of a function and don't include the parenthesis then JavaScript will just treat it as a reference to the function code itself, rather than a function call.

This is actually rather useful as passing function references around is a pretty common thing to do in JavaScript, but that is a far more advanced subject which won't come up until a much later course.