JS变量命名规范

来源:互联网 发布:南京知行汽车 编辑:程序博客网 时间:2024/05/16 08:34

1、必须以字母、下划线或美元符号开头,后面可以跟字母、下划线、美元符号和数字。如下:

正确:

hello            _hello         $hello    

错误:

  6hello      //开头不能用数字  %hello     //开头不能用除(_ $)外特殊符号,如(%  + /等)  hello+js //开头中间不能使用除(_ $)外特殊符号,如(%  + /等)

2、变量中区分大小写,如A与a是两个不同的变量名。

3、不允许使用JavaScript关键了和保留字作变量名。

关键字 break case catch default delete do else finally for if in instance of new return switch throw try type of var void while
保留字 abstract boolean byte char class const debugger enum export extends final float goto implements int interface long native package private protected short static super synchronized throws transient volatile
0 0
原创粉丝点击