1, expression:
The simplest expression: the direct amount or variable name. Var a = 1;
Value of the direct expression: itself.
Variable expression value: the value that the variable stores or references.
2, operator:
Unary operator: for example,-3
Binary operators: for example, 3 + 4
Ternary operators: such? :
Problems frequently encountered by beginners:
Increment operator:
For example:
I = 1;
J = ++ I; // increment the number of operations first, and then calculate.
// Output I = 2; j = 2;
I = 1;
J = I ++; // then, the incremental operation is performed, that is, the calculation is performed first, and then the number of operations is incremented.
// Output I = 2; j = 1;
3. Equal operators:
=: Value assignment operator;
=: Equal operator;
===: Equivalent operator;
The value NaN will never be equal to any value, including itself.
Alert (NaN = NaN); // false NaN indicates Not a Number
To check whether a value is NaN, you can use the global function isNaN ();
Note the following for beginners:
Var a = [1, 2, 3];
Var B = [1, 2, 3];
Document. write (a = B); // output false. (This is actually the content of Chapter 1 .)
// Although the values are the same, the types are the same, but the addresses are different.
--------------------------------------------------------
Var a = [1, 2, 3];
Var B =;
Var c =;
Document. write (B = c); // Output true;
--------------------------------------------------------
Var a = "1 ";
Var B = true;
Document. write (a = B); // Output true
Document. write (a = B); // the output value is false. The values are the same and the types are different.
4. Comparison operators:
It should be noted that the string is to be cut and compared.
It is case sensitive.
If your requirement is case insensitive:
You can use String. toLowerCase () // lowercase only
String. toUpperCase () // convert it in uppercase and then compare it.
5, in OPERATOR:
Note that the value on the left is the property of the object on the right.
For example:
Var a = {x: 1, y: 2 };
Var B = "x" in a; // true
Var c = "toString" in a; // true. The value on the left is the attribute of the object on the right.
6 instanceof OPERATOR:
Note that the Operation number on the left is an object, and the operation number on the right is the name of the object class.
For example:
Var a = new Date ()
A instanceof Date; // true
A instanceof Object; // true
A instanceof Number; // false
7, 3 element conditional operators:
Note that the first operation must be a Boolean value.
X> 0? 3: 2;