Regarding naming, ES itself is pretty consistent: - Types are PascalCase. Ex: WeakMap - Non-symbol constants are UPPER_SNAKE_CASED. Ex: Number.MAX_SAFE_INTEGER - Initalisms within names are always lower case if first and not part of a type name, upper case otherwise. Ex: JSON, Date.prototype.toJSON - Everything else is camelCase. Ex: Symbol.hasInstance, Object.keys
It's the DOM and HTML APIs that are inconsistent, typically for historical reasons. On Fri, Jul 14, 2017, 03:22 TOYAMA Nao <[email protected]> wrote: > Microsoft said "XMLHttpRequest" in August 1999 [*1], a month before > feature request for Mozilla [*2]. > > [*1] > > https://web.archive.org/web/19990828184122/http://msdn.microsoft.com/xml/reference/scriptref/XMLHttpRequest_Object.asp > [*2] https://bugzilla.mozilla.org/show_bug.cgi?id=15119 > > On 2017/07/12 5:53, Alexander Jones wrote: > > Just for funsies I looked this up - In the interests of honesty I should > > point out that apparently it was Mozilla who named this `XMLHttpRequest` > > thing. > > > https://softwareengineering.stackexchange.com/questions/157375/why-does-xmlhttprequest-not-seem-to-follow-a-naming-convention > > > > On 11 July 2017 at 13:07, Alexander Jones <[email protected] > > <mailto:[email protected]>> wrote: > > > > 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 > > [email protected] > > https://mail.mozilla.org/listinfo/es-discuss > > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

