The variable way in normal.
var a = 10; for integers.
var b = 3.14; The decimal point to target.
var c = "Hello"; a double quote or single quotation mark is the definition string.
One, type conversion (CAST)
1, parseint (d), integer conversion.
2, Parefloat (d); Decimal conversion.
Second, operator and expression
1. Mathematical operators:
+-*/% to take the remainder
%: Take the remainder.
Third, logical operators
① if two conditions are true at the same time.
&& : At the same time, two conditions are established and must be at the same time. and meaning.
② if only one of the two conditions satisfies or is satisfied.
|| or : One or two must be met.
③ If this value is false, the front Plus is true, if the condition is true, plus or not is false.
! Non : logical inversion.
The circuit is also divided into this way.
Often used when judging conditions.
Four, comparison operators:
①==: Judgment equals. One is used to assign a value, and two is equal to.
= = = Horizontal and so on.
Ii! =: Not equal to.
Example: A!b; A is not equal to B.
>< representative does not equal.
③>: Greater than.
④<: Less than.
⑤>=: greater than or equal.
⑥<=: Less than equals.
V. Concatenation of strings: +
Cases:
var " hehe " ; var " haha " ; var s = str1+Str2;alert (s) Plus is not a mathematical operation here, but a concatenation of strings. You can stitch more than one at a time.
Six or three wood operators:
Simple to judge the condition.
Cases:
A==b returns an equal to
A!=b returns a not equal to
A ==b? " equals "If a equals B, it returns a equals."
A ==b? " equals ":" Not Equal to "
If the condition is met, return to the previous.
If the condition is not satisfied, return to the back.
Structure:
Conditions? : The return content that satisfies the condition: what content is returned if the condition is not satisfied;
Seven, JS statements
1. Sequential statements: Execute from top to bottom, plus one after each statement;
2. Branch statement:
The execution of the program encounters a place to be executed separately.
Execution encounters a condition that, if satisfied, resumes execution. If it is not satisfied, perform the other.
Intelligence is done by branching out.
Cases:
A==b, let the program judge:
if (a==B) Else : The condition does not satisfy {The code executed to satisfy the condition;} {else does not satisfy the conditional execution code}
The central common form of if:
① Simple: if
Cases:
if (a==b) {alert (a+b);}
If a equals b I will output the value of a+b.
If a is not equal to B, no action is taken.
So you can use the if without some alert.
Usage of ②if and else:
if(a==b) {alert (a+b);} Else {alert (a*b);}
If a equals B, the value of the a+b is output.
If a is not equal to B, the value of a*b is output.
Example 2:
if (a>) {alert (" too expensive ");} Else {alert (" also available ");} Else {alert (" too cheap ")}
Nesting of ③if
if (a>if(b>5) {alert ();}}
if (a>b && b>5) Two conditions are met before you can go.
if (a>b | | b>5) Two conditions satisfy one can go.
3. Cyclic execution:
It is possible that the same code executes multiple times. Perform some content repeatedly.
The use of if and else in JS and the underlying syntax