1、语法错误
It is important to pay attention to detail when you write scripts. For example, strings must be enclosed in quotation marks.
2、代码解释顺序
JavaScript interpretation is part of the your Web browser's HTML parsing process. If you place a script inside the <HEAD> tag in a document, it is interpreted before any part of the <BODY> tag. If you have objects that are created in the <BODY> tag, they do not exist at the time the <HEAD> is being parsed, and cannot be manipulated by the script.
3、类型强制转换Corecion/Converter
JavaScript is a loosely-typed language with automatic coercion. Even though values having different types are not equal, the expressions in the following example evaluate to true.
"100" == 100; false == 0;
To check that both the type and value are the same, use the strict equality operator (===). The following both evaluate to false:
"100" === 100; false === 0;
4、符号优先级
Operator precedence determines when an operation is performed during the evaluation of an expression.
5、for...in遍历object属性
When you iterate through the properties of an object with a for...in loop, you cannot predict or control the order in which the fields of the object are assigned to the loop counter variable. Moreover, the order may be different in different implementations of the language.
6、with关键字
The with statement is convenient for accessing properties that already exist in a specified object, but cannot be used to add properties to an object. To create new properties in an object, you must refer to the object specifically.
7、this关键字
Although you use the this keyword inside the definition of an object to refer to the object itself, you cannot use this or similar keywords to refer to the currently executing function when that function is not an object definition. If the function is to be assigned to an object as a method, you can use the thiskeyword within the function to refer to the object.
8、Writing a Script That Writes a Script in Internet Explorer
The </SCRIPT> tag terminates the current script if the interpreter encounters it. To display "</SCRIPT>" itself, rewrite this as at least two strings, for example, "</SCR" and "IPT>", which you can then concatenate together in the statement that writes them out.
9、Implicit Window References in Internet Explorer
Because more than one window can be open at a time, any implicit window reference points to the current window. For other windows, you must use an explicit reference.
浙公网安备 33010602011771号