简体   繁体   English

ECMAScript 是否区分大小写?

[英]Is ECMAScript case sensitive?

I understand that JavaScript (the language that implements the spec) is case sensitive .我知道 JavaScript (实现规范的语言) 是区分大小写的。 For example, variable names:例如,变量名:

let myVar = 1
let MyVar = 2 // different :)

I haven't been able to find anything in the spec itself that indicates that this is a requirement, so I'm not sure if that was just a design decision independent of the spec.我无法在规范本身中找到任何表明这是一项要求的内容,所以我不确定这是否只是一个独立于规范的设计决策。

I think I found something that specifies this.我想我找到了一些说明这一点的东西。 Names and Keywords says:名称和关键字说:

Two IdentifierNames that are canonically equivalent according to the Unicode standard are not equal unless, after replacement of each UnicodeEscapeSequence , they are represented by the exact same sequence of code points.根据 Unicode 标准规范等效的两个IdentifierName相等,除非在替换每个UnicodeEscapeSequence之后,它们由完全相同的代码点序列表示。

Since uppercase and lowercase letters have different code points, identifiers with different case are not equal.由于大写和小写字母有不同的码位,不同大小写的标识符是不相等的。

Yes it is case sensitive but generally JavaScript developers follow camel case convention.的,它区分大小写,但通常 JavaScript 开发人员遵循骆驼大小写约定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM