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 trialLee Ravenberg
10,018 PointsWhy not use a Uppercase character at the beginning of your object name?
Why are we learning to write our object names all lowercase in JavaScript. In other languages you get slapped by peers if you don't write a class name, starting with uppercase. Hmm...
2 Answers
anil rahman
7,786 PointsYeah thats true. But in javascript that key thing to denote ok i am now going to make an object and it will contain a few things is the {} brackets really.
The var just says it will be whatever types are in the object.
and then you give it a name.
So instead of this
Shanghai shanghai = new Shanghai();
You have a super simple version that does type checking for you:
var shanghai = { //properties go here };
anil rahman
7,786 PointsBut isn't that just the same as:
Shanghai shanghai = new Shanghai();
Where the lowercase object name is the name used for accessing the methods and properties of that object. It seems like the correct way to me.
Lee Ravenberg
10,018 PointsGood point! Its totally different. But even when declaring your object litteral using the var keyword you arent writing it down with an Uppercase character. How am I supposed to know that this particular variable is of an object type without this notation or studying the original declaration.. Just seems so strange in comparison what I learned about OOP in other languages.