ECMAScript——命名规范

一、js中是严格区分大小写的
test和Test是两个名字

二、使用驼峰命名法
第一个首字母小写,其他每个有意义的单词的首字母都要大写
能够使用字母、数字、下划线、$命名,可是数字不能做为开头,如:
学生信息: studentInfo studentInfo2
人员的重要信息: personImportInfo
$person:一般项目中这种名字表明的是jQuery专用的名字

三、不能使用关键字和保留字
关键字:js中具备特殊意义的词,咱们不能随便拿来命名
保留字:将来可能会成为关键字的

关键字:javascript

breakjava

casethis

catchspa

continuedebug

defaultip

deleteget

doit

elseio

finallytable

for

function

if

in

instanceof

new

return

switch

this

throw

try

typeof

var

void

while

with

保留字:

abstract

boolean

byte

char

class

const

debugger

double

enum

export

extends

final

float

goto

implements

import

int

interface

long

native

package

private

protected

public

short

static

super

synchronized

throws

transient

volatile

 

 

 

 

 

 四、对于全局变量或者公用的变量咱们最好起名字的时候前面加上 _ ,例如:_this、_num这些都表明是公用的变量

相关文章
相关标签/搜索