為什么第一個if后面,要用到兩個等號(test==true)。第二個if后面,為什么要用嘆號呢?null代表什么?(test!=null)
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? function openWindow(){
? ? ? var test1=confirm("是否打開網頁?");
? ? ? if(test1==true){
? ? ? var test2=prompt("是否打開這個網頁?","http://www.xianlaiwan.cn/");
? ? ? if(test2!=null){
? ? ? window.open('http://www.xianlaiwan.cn/','width=400,height=500,menubar=no,toolbar=no');}
? ? ? else{
? ? ? ? ? alert("已取消打開imooc了!");
? ? ? }
? ? ? }
? ? ? else{
? ? ? ? ? alert("已取消!");
? ? ? }
? ? ? }
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2016-06-29
操作符 '=' 可以看作是賦值操作
操作符 '==' 和 '===' 可以看作是判斷操作,前者是判斷值相等,后者是判斷完全相等(包括類型)
第一個if語句就是判斷語句啦,當判斷條件內部為真(true)時,執行大括號內語句
第二個if里面的操作符是 '!=' 代表不相等,當test2和null不相等時,判斷條件為真(true),執行大括號內語句
另外null表示值為空,是js的一種變量類型,通??梢杂脕砬蹇漳硞€變量
2016-06-29
== ?是判斷前面和后面的是等值 也就是一樣 ? != ?是判斷前面的不等于后面的
2016-06-29
=代表賦值
a=b表示為a賦值為b
==代表等于
a==b可以理解為a等于b
!=代表不等于
null代表空
2016-06-29
!? 就是 不是的意思 ,? null 就是 空的意思,? 所以 !=null 的意思就是? 不是假的?
=號是賦值?? ==就是是等于了???