Core tips: Walkthrough of JavaScript operator Instance
Depending on the number of objects processed:
Cell operator;
binary operator;
Ternary operator.
According to the function:
Assignment operator;
= + = = *=/=%= (take more)
arithmetic operators;
+-*/% (remainder) + + (incremental)--(descending)-
Example 1:
Example 2:
<br/><Script> <br/>var x = y = 3; <br/>with (document) {<br/> write ("x = 3, y = 3 <br>"); <br/> Write ("If x = after y++ operation:"); &L t;br/> x = y++;//y→x,y+1→y <br/> Write ("x is", X, "; Y is ", Y, <br>"); <br/> write ("Again x = ++y operation:"); <br/> x = ++y;//y+1→x,y+1→y <br/> Write ("x is", X, "; Y is ", y); <br/>} <br/></Script>
string operators;
+ + =
comparison operators;
= =!= = = = (value and type)!== (value and type)
< <= > >=
Cases:
<br/><Script> <br/>var x = 5; X is the value 5 <br/>var y = ' 5 '; Y is the string 5 <br/>var z = 6; X is the value 6 <br/>with (document) {<br/> write ("x = 5, y = ' 5 ', z = 6"); <br/> write ("<li>x = = y? ", x = = y); <br/> Write ("<li>x = = y?") ", x = = y); <br/> write ("<li>x!= y?") ", x!= y); <br/> write ("<li>x!== y?") ", x!== y); <br/> write ("<li>x <= z?") ", x <= z); <br/> write ("<li>y <= z?") ", y <= z); <br/>/Type automatic conversion <br/>} <br/></Script>
logical operators;
&&!
Example 1:
<br/><Script> <br/>var t = true; <br/>var F = false; <br/>with (document) {<br/>write (Result of "<ol><li>true && true", T && t); <br/>write ("<li>true && false result is", T && F); <br/>write (Result of "<li>false && true", F && t); <br/>write ("<li>false && false result is", F && f); <br/>write ("<li>true && (1==1) results are", T && (1==1)); <br/>write (The result of "<li>false && ' A" is ", F && ' a"); <br/>write ("<LI> ' a ' && false result is", ' a ' && f); <br/>write (The result of "<li>true && ' A" is ", T && ' a '); <br/>write ("<LI> ' a ' && true result is", ' a ' && t); The result of <br/>write ("<LI> ' a ' && ' B ') is", ' a ' && ' B '); <br/> //&&: One is not a logical value, the value of the first operand is returned flase if the value of the first operand is flase, otherwise the value of the second operand is returned <BR />} <br/></Script>
1 2 Next page > full text reading tips: Try "←→" button, turn the page more convenient Oh!
[1] [2] Next page