JavaScript ?? ? ???? ???
?? ???
??? ?? ? ?? ??
== 2 == 3 SE
=== ?? ?? ( ?? ??? ?? ????? ???. ??) (2 === 2 TRUE) (2 === "2" FALSE )
!= ?? ??, <> 2 == 3 TRUE
> ; 3 FALSE
< 2 ?? < 3 TRUE
>= 2 ?? >= 3 FALSE
<= 2 ?? <= 3 TRUE
??? ???? ??? ? ????.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var a=5,b="5"; document.write(a==b); document.write("<br />"); document.write(a===b); document.write("<br />"); document.write(a!=b); document.write("<br />"); document.write(a!==b); </script> </head> <body> </body> </html>
?? ???
??? ?? ? ?? ??
&& ?? AND (???) x = 2 y = 6 X &&; y & gt; 5 false
|| ?? ??(??) y = 6; x || y & gt; !(x > y) TRUE
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> var a=5,b="5"; document.write(a&&b > 10); document.write("<br />"); document.write(a||b <6); document.write("<br />"); document.write(!(a>b)); </script> </head> <body> </body> </html>
??? ???
JavaScript?? ?? ??? ?? ??? ?? ???? ??? ???? ???? ????.
Syntax
?? ??=(??)?value1:value2
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> 年齡:<input id="age" value="18" /> <p>是否達到上學年齡?</p> <button onclick="myFunction()">點擊按鈕</button> <p id="demo"></p> <script> function myFunction() { var age,voteable; age=document.getElementById("age").value; voteable=(age<7)?"年齡太小,繼續(xù)幼兒園":"年齡已達到,可以入學"; document.getElementById("demo").innerHTML=voteable; } </script> </body> </html>