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) 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"