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 Foundations Strings Methods: Part 2

Roy Huang
Roy Huang
4,367 Points

Parentheses for Methods?

Hello , I would like to know when do we need empty parentheses to invoke methods?

I learned in the video, it said that like .toLowerCase, we need empty parentheses; however ,like .length, we don't need parentheses.

I was confused: When do we need parentheses?

Thank you for your help.

1 Answer

Stone Preston
Stone Preston
42,016 Points

you need parenthesis when invoking method calls. For example you need parenthesis when calling the toLowerCase() method. However length is a property of Strings, not a method, which is why you don't need parenthesis.

see the Mozilla docs on Strings for more information

Roy Huang
Roy Huang
4,367 Points

Thank you for your prompt answer.

So they are different and I just got confused.

Thank you !