(1)JavaScript是区分大小写的,但是HTML是不区分大小写的,CSS又是区分大小写的;
(2)显示结果一样的字符,由可能编码不一样;
(3)对象直接量:{x:1,y:2}
(4)数组直接量:[1,2,3,4,5]
(5)JavaScript标识符规则:标识符包含字母、数字、下划线、$符号,但是不能用数字作为首字母。
(6)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 try
保留关键字,也绝对不能用(ECMAScript 5中的保留关键字)
class const enum export extends import super
严格模式下不能使用:
implements let private public field interface package protected static
严格模式下尽量不用:
arguments eval abstract double goto native boolean byte synchronized
char int throws final transient float long short volatile
预定义全局变量和函数,避免使用:
arguments encodeURI Infinity Number RegExp Array encodeURIComponent
ifFinite Object String Boolean Error isNaN parseFloat
SyntaxError Date eval JSON parseInt TypeError decodeURIComponent
Function NaN ReferenceError URIError
(7)行末分好可以省略,但会可能导致意想不到的后果(系统会按照自己规则添加行末分号,结果可能不是想象中的表达式)。谨慎的程序员会在行前先加分号。例如:
var y = x + f
(a+b).toString()
最终解析为:var y = x + f(a+b).toString();
return
true;
这个代码会解析为:return;true;