Increment and Decrement
Should these be added too?
| **New syntax** | **Equivalent ES2023** |
|:--:|:--:|
| `expr1?.prop++` | `expr1 == null ? undefined : expr1.prop++` |
| `expr1?.[key]++` | `expr1 == null ? undefined : expr1[key]++` |
| `expr1?.foo().prop[key]++` | `expr1 == null ? undefined : expr1.foo().prop[key]++` |
| `++expr1?.prop` | `expr1 == null ? undefined : ++expr1.prop` |
| `expr1?.prop--` | `expr1 == null ? undefined : expr1.prop--` |
| `--expr1?.prop` | `expr1 == null ? undefined : --expr1.prop` |
In C# 14 (https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-10-28.md#increment-and-decrement-operators-in-null-conditional-access), they didn't do them because
> Technically, the prefix operators would be difficult, and the outcome may not be what the programmer anticipated. Doing postfix, but not prefix operators may seem odd.
0 条评论