<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// 1.逻辑与(左边是假就短路,即后面不再执行)
// function fn(x, y){
// x = x && 0
// y = y && 0
// console.log(x + y)
// }
// fn()
// 2.逻辑或(左边是真就短路)
function fn(x, y){
x = x || 0
console.log(x)
y = y || 0
console.log(x + y) //0
}
fn()
console.log(11 || 55) //11
</script>
</body>
</html>
13_逻辑中断
最新推荐文章于 2024-07-20 10:36:53 发布