前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >逻辑与 逻辑或 特殊情况

逻辑与 逻辑或 特殊情况

原创
作者头像
云台大树
修改2021-08-25 11:29:28
5670
修改2021-08-25 11:29:28
举报
代码语言:javascript
复制
let str = a\nb;
console.log(str);
console.log(typeof str);
function foo1(){
  console.log('ex1');
}
function foo2(){
  console.log('ex2');
  return 2;
}
console.log(foo1() || foo2());
// console.log(foo() && false);
// console.log(0 && foo());
/*
The || operator, for example, will return the value to its left when that can be converted to true and will return the value on its right otherwise.
逻辑或操作符,如果左边的结果等同于true,则返回左边的结果;否则返回右边的结果
*/
/*
The && operator works similarly but the other way around. When the value to its left is something that converts to false, it returns that value, and otherwise it returns the value on its right.
逻辑与操作符,如果左边的结果等同于false,则返回该结果;否则右边的结果
*/

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com