Re: Feature Detection



"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'

.



Relevant Pages

  • Re: Feature Detection
    ... All upper case ... Camel case ... The specification merely reflects the convention, ... The authors of ECMA-262 decided to exempt operators from that ...
    (comp.lang.javascript)
  • Re: unchecked cast
    ... stringent convention. ... is always written in all-lowercase ASCII letters ... all, but it's not technically a violation of the convention, nor is ... failing to use camel case. ...
    (comp.lang.java.programmer)
  • Re: Don was saying...
    ... > bok wrote: ... R and r are upper and lower case letters respectively. ... > Just flies in the face of two hundred years of convention is all. ...
    (sci.energy.hydrogen)
  • Re: unchecked cast
    ... The Sun naming convention document says: ... The examples given in that document are not camel case but all lower ... The JLS suggests use of underscores in package names as well. ...
    (comp.lang.java.programmer)
  • Re: Don was saying...
    ... bok wrote: ... > Don Lancaster wrote: ... R and r are upper and lower case letters respectively. ... Just flies in the face of two hundred years of convention is all. ...
    (sci.energy.hydrogen)