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

executing methods

Why do some methods such as .toUpperCase require () to execute while others such as .length do not?

2 Answers

James Barnett
James Barnett
39,199 Points

Because .length actually is not technically a method its a property.

You can think of them this way:

  • Properties are like nouns. They have a value or state.
  • Methods are like verbs. They perform actions.

Methods require parentheses because they are a type of function and all functions require parentheses even if they don't take any arguments.

further reading: https://www.utexas.edu/learn/javascript/objects.html

Thank you, your answer was really helpful!