Posts 运算符
Post
Cancel

运算符

1
2
3
4
5
6
7
8
9
10
?.  对象深处的属性或与函数调用,若引用为空(null or undefined), 返回 undefined

a || b => a ? a : b
a && b => !a ? a : b
a ?? b => a !== undefined && a!== null ?a:b

??= => a ??= b (a不为null和undefined时被赋值)
||= => a ||= b (a存在时返回a, 否则赋值为b)

!!
This post is licensed under CC BY 4.0 by the author.