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
ES 2020
nullish coalescing operator (??)
空值合并操作符
refs
©xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!