【发布时间】:2018-09-27 01:49:30
【问题描述】:
我们在.NET 中有 Null 合并运算符,我们可以如下使用
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
【问题讨论】:
标签: javascript .net reactjs typescript null-check