关键字就是有特殊用途的字符串,关键字被语言保留,不能用作标识符。
JavaScript的关键字有:
break case catch continue default delete do else finally for function if in instanceof new return switch this throw try typeof var void while with
ECMA-262标准还规定了另外一组字符串不能作为表示符---保留字。
JavaScript的保留字有:
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
变量:
变量是用来存储数据的,JavaScript定义变量十分简单,只需要使用var关键字和变量名即可。
var message;
上面代码声明的变量message可以存储任何类型的值。
我们还可以使用一条语句定于多个变量:
var message="hi", foo=false, score=80;