我们在.NET中有空合并运算符,可以使用如下方式:
我需要像.NET功能一样的特性,是否可以在使用React JS时使用TypeScript实现呢?
类似于:
```
string postal_code = address?.postal_code;
React JS也可以做同样的事情吗?
我发现我们可以使用 && 运算符
在 address.ts 文件中
string postal_code = address && address.postal_code;
我需要像.NET功能一样的特性,是否可以在使用React JS时使用TypeScript实现呢?
类似于:
string postal_code = address?.postal_code // I am getting the error in this line if I try to use like .NET