JavaScript_2강_3_논리 연산자

열라뽕따히·2024년 3월 7일

JavaScript

목록 보기
7/37

논리연산자(&&, ||, !)


=============================코드=============================

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

		// 논리연산자(&&, ||, !)
		let bol1 = true, bol2 = false, 
			 bol3 = true, bol4 = false;
		
		document.write(`${bol1} && ${bol2} >>> ${bol1 && bol2} <br/>`); 
		// true && false ==> false
		
		document.write(`${bol1} && ${bol3} >>> ${bol1 && bol3} <br/>`); 
		// true && true ==> true
		
		document.write(`${bol2} || ${bol3} >>> ${bol2 || bol3} <br/>`);  
		// false || true ==> true
		
		document.write(`${bol3} || ${bol4} >>> ${bol3 || bol4} <br/>`); 
		// true || false ==> true
		
		document.write(`<hr>`);

/////////////////////////////////////////
		let a = "A", b = "B";
		
		// 3은 true 0은 false  
		// !2는 false
		let c = !2 || 3 && !0; // ==> 3(true) && !0(true)  / !2(false) || true ==> true
		document.write(`c >>> ${c} <br/>`);

		// true || false ==> true
		c = a < b || a == b;
		document.write(`c >>> ${c} <br/>`);

</script>
</head>
<body>

</body>
</html>

=============================실행=============================

0개의 댓글