javascript中使用关键字和保留字作为属性

可作为属性的关键字和保留字有

abstract,int,short,boolean,interface,static,byte,long,char,final,native,synchronized,float,package,throws,goto,private,transient,implements,protected,volatile,double,public,supper,implements,package,public,interface,private,static,let,protected,yield

不可作为属性的关键字和保留字有

break,do,instanceof,typeof,case,else,new,var,catch,finally,return,void,continue,for,switch,while,debugger,function,this,with,default,if,throw,delete,in,try,enum,export,extends,super,class,const,debugger,import,class,enum,extends,const,export,import

var a={};
a.goto=1;//正常运行
a.this=1;//报错
a['delete']=1;//正确写法

猜你喜欢

转载自my.oschina.net/u/818899/blog/901775