<!DOCTYPE> <html> <head> <meta http-equiv="Content-Type" content="text.html;charset=utf-8"> <title></title> <script> var addf=confirm("您好 想要进入该网站吗"); if(true){ document.write("欢迎访问本网站 很高兴为你服务"); } else { alert("谢谢 忍痛拒绝"); } </script>
数据分析师2017-09-30 23:35:30
Can I write variables directly or write true in the brackets after if? Please give me some advice. What will be the result if I write these two? -PHP Chinese website Q&A - Can I write variables directly or write true in the brackets after if? Please give me some advice. What will be the consequences if I write these two? -PHP Chinese website Q&A
Please watch and learn.
迷茫2016-12-22 13:28:19
因为if后面的判断语句就是要判断执行if还是else后面的语句,如果你直接写if(true)的话,if后面永远是true,也就是说无论前面如何改变,都永远执行if里面的语句,不会执行else里面的语句。