I. js supports Unicode character sets, so you can use Chinese naming functions.
Ii. js does not have initialization variables in Var. The default value is undefined.
III. For variables that are neither declared nor assigned values, if directly used, a system-level Error will be thrown. If typeof (typeof is a type operator) is used, whether it is declared or not, an undefined string is returned ";
Example:
// A is not declared
Alert (typeof (a); // undefined
Alert (a); // Error
4. Arithmetic Operators. "+" Can be used to easily convert a value into a string. The specific operation is to add this value to an empty string (or not to write ).
Example:
Var a = 2.96;
Var B = 1.0;
Alert (a + "+ B); // obtain the string" 2.961"
You can use "-" to replace a string with a value. The specific operation is to subtract a value 0 from the string.
Var a = "2.96 ";
Alert (a + 1); // obtain the string "2.961" (forcibly convert the value to a string)
Alert (a-0 + 1); // get the value 3.96
Here is an example I made:
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> js </title>
<Script language = "javascript">
X = 5 + 5;
Document. write (x + "<br> ");
X = "5" + "1 ";
Document. write (x + "<br> ");
X = "5" + 5;
Document. write (x + "<br> ");
X = "10"-5;
Document. write (x + "<br> ");
</Script>
</Head>
<Body>
</Body>
</Html>
Result:
10
51
55
5