xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

js logical operation All In One

js logical operation All In One

js 逻辑运算

Logical AND (&&)
Logical AND assignment (&&=)
Logical OR (||)
Logical OR assignment (||=)
Logical NOT (!)
Logical nullish assignment (??=)

Logical AND (&&)

逻辑

Logical OR (||)

逻辑

const a = 3;
const b = -2;

console.log(a > 0 || b > 0);
// expected output: true

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR

Logical NOT (!)

逻辑非

Logical nullish assignment (??=)

逻辑空值合并

const foo = null ?? 'default string';
console.log(foo);
// "default string"

const baz = 0 ?? 42;
console.log(baz);
// 0

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator

ES 2020

nullish coalescing operator (??)

空值合并操作符

refs



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2020-08-20 16:01  xgqfrms  阅读(168)  评论(4编辑  收藏  举报