1.目前的关键字:
try......catch......throw
if......else
do......while......for
switch......case
function......return......void
true......false
break......continue
debugger
default
delete
finally
in
instanceof
new
null
this
typeof
var
with
2.es5的保留字:
class const enum extends import super
*严格模式下是保留字的:
implements let private public yield interface package protected static
*不能用做变量名/函数名/参数名:
arguments eval
3.es3将java所有的关键字都列为自己的保留字:
abstract boolean char byte class const double enum export extends final float goto implements import int interface long native packge private protected public short static super synchronized throws transient volatile
4.javascript预定义的全局变量和函数
arguments encodeURI Infinity Number RegExp Array encodeURIComponent isFinite Object String Boolean Error isNaN parseFloat SyntaxError Date eval JSON parseInt TypeError DecodeURI decodeURIComponent EvalError Function Math NaN RangeError ReferenceError undefined
URIError
关键字很多,但是只要稍微注意,就不会冲突啦
本文详细列举了JavaScript中的关键字与不同版本ES规范下的保留字,并提到了一些预定义的全局变量和函数。了解这些内容有助于避免变量命名冲突,确保代码的正确性和可读性。

2258

被折叠的 条评论
为什么被折叠?



