Occasionally this comes up when deciding on a spelling for something. There
are numerous examples in ECMAScript and other Web standards that seem to
defy the most uniform convention:

 * `JSON` vs. `Json`
 * `toJSON` vs. `toJson`
 * `XMLHttpRequest` vs. `XmlHttpRequest`
 * `DOMElement` vs. `DomElement`

While it looks initially strange to specifically drop the capital letters
on an initialisms like XML, the rule is simple in that it has an obvious
machine decoding - a capital letter starts a new word. Thus, translations
of identifiers to other case conventions are automatic (so long as numbers
never appear at the start of a word). This helps a lot when e.g. generating
bindings for IDLs to different languages, or in general interfacing
different systems that really, really want to use their own naming
conventions.

 * mixed case: `myTlaIdentifierHere`
 * pascal case: `MyTlaIdentifierHere`
 * underscore case: `my_tla_identifier_here`
 * uppercase: `MY_TLA_IDENTIFIER_HERE`
 * kebab case: `my-tla-identifier-here`
 * spaces case: `my tla identifier here`

---

My question is whether there is an existing community recommendation
anywhere for naming ECMAScript identifiers. Clearly, when Microsoft devised
the name `XMLHttpRequest`, someone was having a difficult time figuring out
how to spell adjacent initialisms in PascalCase.

If there is no recommendation, perhaps there should be? Is there any scope
for non-normative sections of information like this in the ECMAScript spec?

Thanks

Alex
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to