保留字,变量——JavaScript知识小结03

来源:互联网 发布:胡安巴尔加斯数据 编辑:程序博客网 时间:2024/05/29 08:08
一.保留字
Reserved Words:A reserved word is an IdentifierName that cannot be used as an Identifier.
保留字:不可以用来当作标识符的标识符名
ReservedWord::
Keyword
FutureReservedWord
NullLiteral
BooleanLiteral

Keyword::红色代表es6新增,黄色代表es5新增
break     do
in typeof case else instanceof var catch export new void class extends return while const finallysuper with continue for switch yield debugger function this default if throw deleteimport try
第五版:
非严格模式下保留字:
class enum extends super const export import
严格模式下保留字:
implements package public interface private static let protected yield
第六版:
Future Reserved Word::
enum await( await is only treated as a FutureReservedWord when Module is the goal symbol of the syntactic grammar.

Use of the following tokens within strict mode code is also reserved. That usage is restricted using static semantic restrictions (see 12.1.1) rather than the lexical grammar:
implementspackageprotected interfaceprivatepublic
二.变量
ECMAScript变量是松散的,即可以用来保存任何类型的数据。
在几个函数中,不加 var ,在执行一次后,该变量将会变成全局变量。
严格模式下,未加var会抛出错误。
严格模式下,不能定义名为eval与arguments的变量,否则会导致语法错误。
定义形式

var a = "hi",
    b = false,
    c = 29;

参考资料:ECMA标准:http://www.ecma-international.org/ecma-262/7.0/index.html#prod-Keyword
               《JavaScript高级程序设计(第三版)》
阅读全文
0 0
原创粉丝点击