Re: Feature Detection
- From: Lasse Reichstein Nielsen <lrn.unread@xxxxxxxxx>
- Date: Fri, 13 Feb 2009 07:02:36 +0100
"Trevor Lawrence" <Trevor L.@Canberra> writes:
While it is unlikely that others will read my code, I can try to follow
convention. What I need to find out now is what to use in what cases
All lower case
All upper case
Capitalised
Camel case
I guess it is out there somewhere, maybe in ECMA specs or W3C?.
The specification merely reflects the convention, without saying anything
about it. The convention was originally taken from the Java language
standard notation (Sun's). It's rougly:
Contants are all-upper case, and words are separated by underscores
(example: MY_CONSTANT, FOUR). Since the ECMAScript standard doesn't
allow real constants, this isn't used very much.
Otherwise, always Camel Case identifiers consisting of more than one
word.
"Classes" starts with an upper case letter (in JavaScript that means
constructor function names start with an upper case letter). See, e.g.,
the Number and Object constructors. The "Math" object is an exception,
inherited from Java, where it was a Class with static members instead
of just an object.
Variables and object properties (including methods) start with a lower
case letter: "var foo", "function doBar(theArg, theOther){...}".
Best of luck.
/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'
.
- Follow-Ups:
- Re: Feature Detection
- From: RobG
- Re: Feature Detection
- References:
- Feature Detection
- From: Trevor Lawrence
- Re: Feature Detection
- From: David Mark
- Re: Feature Detection
- From: Trevor Lawrence
- Re: Feature Detection
- From: Lasse Reichstein Nielsen
- Re: Feature Detection
- From: Trevor Lawrence
- Feature Detection
- Prev by Date: Re: bit of regexp help ?
- Next by Date: How to main document History not window history
- Previous by thread: Re: Feature Detection
- Next by thread: Re: Feature Detection
- Index(es):
Relevant Pages
|