Initially, I will perform an HTTP request to a URL in order to retrieve some data.
{
"data": {
"user": {
"name": "john",
"other": [{
"a": 1,
"b": 3
}]
}
}
}
My goal is to check if the 'other' array is null, so I will
if(data!=null && data.user!=null && data.user.other!=null && data.user.other.length>0)
Writing all this code seems laborious and unnecessary. Is there a simpler way to achieve this? In C#, I would do it this way:
if(data?.user?.other?.Any()==true)
{
//dosomething
}
How can I accomplish the same thing using TypeScript?