本文主要是介绍JavaScript学习笔记17-与或非处理复杂的条件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
接着前面一篇文章的内容,这里我们来学习下用逻辑与和逻辑或来处理前面的场景。
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head>
</head>
<body>
<script type ="text/javascript">var firstName = "Anthony";var lastName = "Liu";// 逻辑与if ((firstName == "Anthony") && (lastName == "Liu")){document.write("Yeah, That is my name." + "<br />");}// 逻辑或if ((firstName == "Anthony") || (lastName == "Wang") ){document.write("只要有一个符合就打印");}
</script>
</body>
</html>
上面介绍了逻辑与和逻辑或,逻辑非(!!),可以自己去练习下。这篇关于JavaScript学习笔记17-与或非处理复杂的条件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!