Monday, June 3, 2024
59
rated 0 times [  60] [ 1]  / answers: 1 / hits: 23761  / 15 Years ago, thu, october 8, 2009, 12:00:00

I know this question has no answer, but I'm curious to know what other people think.



In a language like Java, it's a convention to begin classes with capital letters, and objects with lowercase letters. But what about JavaScript, where everything is an object?



I've seen some people suggest capitalizing only objects that are treated as classes; i.e. function objects with a prototype, that are intended to be used with the new operator. Instances of those objects would be lowercased.



That sounds logical. But what do you do about global objects, where there's only one instance? Most people seem to capitalize these (for example, Math or Ext.History). This intuitively feels right, but it's hard to justify it with a consistent rule.



And what about objects that are used as namespaces? These seem to be all over the map: YUI, Ext.util, jQuery, etc.



Please provide secular rationalizations for your heart-felt religious views.


More From » coding-style

 Answers
118

You can follow this Google JavaScript Style Guide



In general, use functionNamesLikeThis, variableNamesLikeThis, ClassNamesLikeThis, EnumNamesLikeThis, methodNamesLikeThis, and SYMBOLIC_CONSTANTS_LIKE_THIS.


[#98546] Monday, October 5, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
payton

Total Points: 307
Total Questions: 96
Total Answers: 83

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
payton questions
Wed, Oct 27, 21, 00:00, 3 Years ago
Fri, Aug 20, 21, 00:00, 3 Years ago
Sun, Apr 11, 21, 00:00, 3 Years ago
Wed, Jun 26, 19, 00:00, 5 Years ago
;