Day13逻辑中断

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>逻辑中断</title>
</head>
<body>
<script>
function fn(x, y) {
x = x || 0
y = y || 0
console.log(x + y)
}
fn(1, 2)
// 逻辑与的中断
// 关键在于与的判断标准是一假则假
console.log(false && 22) //当左边为假时,右边的代码将不再执行 ,并返回左边
console.log(0 && 1 + 33) //此处便返回0,因为0为假,1+33不在执行
// 逻辑或的中断
// 一真则真
console.log(true || 6) //左边为真时,右边的代码不在执行
</script>
</body>
</html>

浙公网安备 33010602011771号