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 trialRuben Dario Avila Home
8,806 PointsWhat is the best practice? CamelCase or Underscore_names ? The right way for names of the variables?
I learn there are two ways of naming the variables, but whats is the best/right way of this, like a PRO Developer?
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Ruben,
Honestly, it all depends on who you ask and what language you are referring to. In JavaScript and jQuery, lower camelCase
is used in the Core, so most programmers will use it in their code. This is the most common naming convention in JavaScript.
Other languages will use upper CamelCase
(or Pascal case) for Functions, Classes, ect. and then under_scores or camelCase for variables and such.
I personally prefer camelCase (I hate the shift-dash thing). But, I do adapt and stick to the most common convention for the language I'm working in.
If you're coding yourself, as long as you are consistent... if your coding with a team, you'll have to follow the norm.
Tushar Singh
Courses Plus Student 8,692 PointsYa I would like to know the answer as well. I use camelCase(in JS) but underscore is easy to read.
thisIsTheRandomText (little difficult to read)
this_is_the_random_text
Konrad Pilch
2,435 PointsKonrad Pilch
2,435 PointsYep :D