javascript - 帕斯卡大小写(或大驼峰大小写)但允​​许使用像 HTMLInputElement 这样的名称?

标签 javascript typescript naming-conventions naming

我正在尝试找到“大小写标准”的定义,该定义允许两个大写字母直接相邻。这方面的一个例子是看似违反规则的 HTMLInputElement。我更喜欢这个,尽管它违反了严格的命名规则,要求它是 HtmlInputElement。有谁知道这个大小写子集是否有正式名称,因为我认为它不符合这些标准中的任何一个......但这也许也是帕斯卡大小写和大 Camel 大小写之间的区别之一,而且它还没有被我在网上找到的现有定义中定义得足够好吗?

最佳答案

我不确定该大小写标准是否存在,我认为这只是驼峰式大小写的一个异常(exception),当有像 HTML 这样的缩写术语时。

这是问题的另一个版本: Acronyms in CamelCase

显然 Microsoft 指南指出(根据 this article):

When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io.

Do not use abbreviations in identifiers or parameter names. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.

虽然颇有争议,但我不确定您的问题是否有完全正确的答案。其中很多内容都是基于意见和解释。

关于javascript - 帕斯卡大小写(或大驼峰大小写)但允​​许使用像 HTMLInputElement 这样的名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61431523/

相关文章:

go - 生成的 go 文件的名称

javascript - 如何将数字向左或向右移动 x 小数位并删除减号?

javascript - 为什么动画没有按预期发生以将框放在底部

javascript - 页面 noscroll 在粘性页脚布局中保持 scrollTop 位置

javascript - Typescript 生成带有 `#private;` 字段的声明 d.ts 文件

java - Java 库和项目中的命名约定

javascript - ionic 后退按钮的问题

javascript - 如何从db中获取数据

typescript - 函数重载错误 : TS7006:Parameter 'x' implicitly has an 'any' type

language-agnostic - 过滤记录的过滤器的另一个名称是什么?