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 trialMichael Godard
5,399 PointsDoes 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
Cena Mayo
55,236 PointsHi 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.
Luke Pettway
16,593 PointsNo 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
17,253 PointsNo, 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"
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsYou can capitalize the first letter of variable any variable but that's used for naming constructors.
Luke Pettway
16,593 PointsLuke Pettway
16,593 PointsBeat me to it!