mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
docs(object): fix #931
This commit is contained in:
parent
add1bb8f82
commit
c4f4570f67
@ -794,7 +794,9 @@ a == null ? undefined : delete a.b
|
||||
|
||||
上面代码中,如果`a`是`undefined`或`null`,会直接返回`undefined`,而不会进行`delete`运算。
|
||||
|
||||
(3)括号不改变运算顺序
|
||||
(3)括号的影响
|
||||
|
||||
如果属性链有圆括号,链判断运算符对圆括号外部没有影响,只对圆括号内部有影响。
|
||||
|
||||
```javascript
|
||||
(a?.b).c
|
||||
@ -802,7 +804,7 @@ a == null ? undefined : delete a.b
|
||||
(a == null ? undefined : a.b).c
|
||||
```
|
||||
|
||||
上面代码中,`?.`对圆括号没有影响,不管`a`对象是否存在,圆括号后面的`.c`总是会执行。
|
||||
上面代码中,`?.`对圆括号外部没有影响,不管`a`对象是否存在,圆括号后面的`.c`总是会执行。
|
||||
|
||||
一般来说,使用`?.`运算符的场合,不应该使用圆括号。
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user