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 Basics (Retired) Storing and Tracking Information with Variables Naming Variables

Does the first letter of a variable name have to be lowercase?

Why do programmers use camelcase as opposed to title case? Can you not capitalize the first letter of a variable name?

4 Answers

Hi Michael,

It depends on the language. In JavaScript, you can technically use capitalized variable names, but the convention is to use lowercase words for variable names, and capitalized words for constructors.

In other languages, such as Ruby, capitalized labels are disallowed for variable names, as they're used by constants, methods, and classes.

Beat me to it!

No and yes. It helps with clarity and in some programming languages it is even required to follow that convention. In Javascript specifically class constructors are always instantiated with a capital letter at the beginning of their name. It would get confusing really quickly if you started variables, classes, and anything else like that.

Piyush Patel
Piyush Patel
17,253 Points

No, it is not a rigid rule. However, in Javascript, most programmers use camel-case notation, meaning you'll use the first word in lowercase and the other words in capitalized format. like "var nameOfPerson"