Camel case
Camel case is a way of writing phrases without spaces, where the first letter of each word is capitalized, except for the first letter of the entire compound word, which may be either upper or lower case. The name comes from the similarity of the capital letters to the humps of a camel's back. It's often stylized as "camelCase" to remind the reader of its appearance.
Camel casing is often used as a variable naming convention. The following variables are in camel case: console
, encodeURIComponent
, ArrayBuffer
, and HTMLElement
.
Note that if the phrase contains acronyms (such as URI
and HTML
), camel casing practices vary. Some prefer to keep all of them capitalized, such as encodeURIComponent
above. This may sometimes lead to ambiguity with multiple consecutive acronyms, such as XMLHTTPRequest
. Others prefer to only capitalize the first letter, as XmlHttpRequest
. The actual global variable, XMLHttpRequest
, uses a mix of both.
When the first letter of the entire phrase is upper case, it is called upper camel case or Pascal case. Otherwise, it is called lower camel case.
Camel case is the most popular convention in JavaScript, Java, and various other languages.
See also
- Related glossary terms:
- typescript-eslint rule:
naming-convention