4 Star 4 Fork 1

梁远东/代码测试合集

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
02.逻辑运算符与短路规则.html 1.14 KB
一键复制 编辑 原始数据 按行查看 历史
梁远东 提交于 2024-08-23 11:52 . 更新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script>
//逻辑 &&(与运算)
console.log(true && 'hello'); // 'hello'
console.log(false && 'hello'); // false
console.log('hello' && true); // true
console.log('hello' && false); // false
// 如果左操作数为真值,那么返回右操作数的值;
// 如果左操作数为假值,那么返回左操作数的值。
// 一旦遇到第一个假值,就会立即返回这个假值,并且不会继续计算后续的操作数
// 逻辑 ||(或运算)
console.log(true || 'hello'); // true
console.log(false || 'hello'); // 'hello'
console.log('hello' || true); // 'hello'
console.log('hello' || false); // 'hello'
// 如果左操作数为真值,那么返回左操作数的值;
// 如果左操作数为假值,那么返回右操作数的值。
// 一旦遇到第一个真值,就会立即返回这个真值,并且不会继续计算后续的操作数
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liang14658fox/code-testing-collection.git
git@gitee.com:liang14658fox/code-testing-collection.git
liang14658fox
code-testing-collection
代码测试合集
master

搜索帮助