close
1 == (3=="3")=true 只在乎值是否相同
2 === (3==="3")=flash 除了值一樣,type也要一樣(因一個是數字,另一個字串)
3 !=
4 !==
5 && 前後結果成立,才成立 (1==1)&&(2==2) =true (1==1)&&(3==2) =flase
6 || 其中一個成立,則成立 (true)||(false) = true
7 ! 取相反數 !(true)=false
8 variablename=(condition)?valuel1:value2
x = (3==2)?0:100; //3等於2成立為0;不成立則為100
<html>
<head>
<script>
function myFun()
{
var x, y=3, z="3";
//x = (y==z); //出現true
//x = (y===z); //出現false
//x=(3==2) && (2=2); //出現false
x =(y==3)?100:0;
document.getElementById("demo").innerHTML=x;
}
</script>
</head>
<body>
<p id="demo">This is paragraph.</p>
<button type="button" onclick="myFun()">
Push me!
</button>
</body>
</html>
全站熱搜