JavaScript学习笔记——语法结构

一、JavaScript程序是用Unicode(万国码、统一码、单一码)字符集编写
二、JavaScript区分大小写的语言,定义关键词、变量、函数名及所有标识符需要统一大小写的形式。var ’tabtang’,’Tabtang’,’TabTang’ //不是同一个变量
三、注释
//后面跟注释的文案、为单行注释
/* 中间为注释的文案、可以换行。为多行注释 */
四、标识符和保留字
①、JavaScript标识符用来对,变量、函数进行命名或某些循环语句的跳转位置的标记。JavaScript标识符,必须以字母、下划线( _ )、美元符号( $ )开始,后续可以跟字母、数字、下划线或美元符号。【注:数字是不允许作为首字母出现的】

②、保留字符
break delete function return typeof
case do if switch var
catch else in this void
continue false instanceof throw while
debugger finally new true with
default for null tyr
ECMAScript5新增
class const enum export import
super
ECMAScript3将Java的所以关键词设为保留
abstract double goto native static
boolean implements package byte private
synchronized char extends int protected
throws final interface public transient
float long short volatile
预定义的全局变量级函数
argument encodeURI Infinity Number RegExp
Array encodeURIComponet isFinite Object String
Boolean Error isNaN parseFloat SyntaxError
Date eval JSON parseInt TypeError
decodeURI EvalError Math RangeError undefined
decodeURIComponet Function NaN ReferenceError URIError

五、可选的分号
————————————————————————————————————–
var a
a
=
3
console.log(a)
解析为 var a; a=3;console.log(a)
————————————————————————————————————–
var y = x+f
(a+b).toString();
解析为: var y = x+f(a+b).toString();
————————————————————————————————————–
var x = 0 //这里可以省略了分号
;[x,x+1,x+2].forEach( console.log ) //前面的分号保证了正确的语句解析
————————————————————————————————————–
return
true;
解析为:return;true
本意 return true
此处不能换行
————————————————————————————————————–
x
++
y
解析为 x; ++y 不是 x++; y
————————————————————————————————————–