js logical operation all in one

js logical operation all in one

逻辑运算

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

js logical operation all in one_第1张图片

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

ES 2020

nullish coalescing operator (??)

空值合并操作符

refs


Flag Counter

©xgqfrms 2012-2020

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


你可能感兴趣的:(js logical operation all in one)