Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Foundations Strings Methods: Part 2

Jorge Cascante
Jorge Cascante
13,582 Points

You say that to invoke a method is necessary to add () But when you used the method length you didn't use it.

how can I know when the parenthesis are necessary to invoke a method?

4 Answers

Kevin Kenger
Kevin Kenger
32,834 Points

Hey Jorge,

Length is actually a property, not a method. For properties, you don't need to add parenthesis. Think of properties like variables. They hold Information about the object, like its length, for instance. Methods are like functions. They're actions that you can call on an object.

Jorge Cascante
Jorge Cascante
13,582 Points

Thanks Kevin. I got confused because it was applied in the video for methods. It makes sense now. I appreciate it.

Kevin Kenger
Kevin Kenger
32,834 Points

No problem. I actually had a hard time deciphering the difference between the two up until pretty recently. It can be pretty confusing.

Annnd...one more thanks to Kevin. I was just starting the video and saw Jorge's question and your answer.

Edgar Gil
Edgar Gil
13,322 Points

Thank you Kevin i just finish doing this video and i understood everything, but thank you for making thing clear now i understand it more.