s ?? nullish coalescing operator and ??= nullish coalescing assignment All In One
js ?? nullish coalescing operator and ??= nullish coalescing assignment All In One
Nullish coalescing assignment (??=)
空值合并赋值
(??=)
Nullish coalescing operator (??)
空值合并运算符
(??)
Logical nullish assignment (??=)
逻辑无效赋值 (??=)
const obj = { duration: 50 };
obj.duration ??= 10;
console.log(a.duration);
// 50
obj.speed ??= 25;
console.log(a.speed);
// 25
obj = {};
// {}
obj['k'] ??= {};
// {}
obj;
// {k: {…}}
obj = {};
// {}
obj['k'] = obj['k'] ?? {};
// {}
obj;
// {k: {…}}
demos
refs
Nullish coalescing assignment (??=)
空合并赋值
(??=)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing
Nullish coalescing operator (??)
空合并运算符
(??)
https://developer.mozilla.org/en-US/docs/Glossary/Nullish
https://twitter.com/harshbothra_/status/1485485358922211328/photo/1
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15841388.html
未经授权禁止转载,违者必究!