The case of capitalization and my in variables


So along with doing codecademy lessons online I am learning code from my boss at work. He is what some would call "old style coding" back in the days when chat rooms online were popular. An interesting question came up when discussing capitalization in variables. Is the capitalization just a new style or is it necessary for the code to function properly? Also, does the my in the examples below do anything (just there for looks) or does it play a part. The question mostly came out of examples like these below.

var = myDude var = mydude var = MyDude var = MYDUDE


It is just a "coding style," but it has been adopted wildly enough to be a coding standard.

  • When someone else is reviewing your code, they expect variables that start with a lowercase to be, well, variables.
  • When something is started with an uppercase, that is typically expected to be a class.
  • When something is all uppercase, that is typically expected to be a constant.

For more details on coding standards, visit the official website for your language of choice.

Here's the one for naming convention in Python:

Here's one from Mozilla Developer Network:

As far as the "my" in your examples, what that does is ensure you don't accidentally use a reserved keyword (which would affect the functionality of your code) when trying to be descriptive about naming your variables. Example: the word new is reserved, so you may want to declare your variable var newentry or var newEntry instead of var new.


Thank you very much! Well explained. I would like that Javascript link too if you still got it


Since Mozilla covers a range of language standards within that page besides JavaScript, I decided to correct the statement listed. They are still a good source for JavaScript, since they did create JavaScript vanilla back in the days of Netscape.

There is another JavaScript standardization body called ECMA that you can visit the specification for:

ECMAScript (or ES)[1] is a trademarked[2] scripting-language specification standardized by Ecma International in ECMA-262 and ISO/IEC 16262. It was based on JavaScript, which now tracks ECMAScript. It is commonly used for client-side scripting on the World Wide Web. Other implementations of ECMAScript include JScript and ActionScript.


Yeah I saw that after i asked the question. These will be very nice resources. But yeah thanks for that links!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.