I realize this is answered, but there is another option when you're dealing with objects.
If you have an object that might be:
{
name: {
first: "John",
last: "Doe"
}
}
You can use:
obj.get(property_name, value_if_null)
Like:
obj.get("name", {}).get("first", "Name is missing")
By adding {}
as the default value, if "name" is missing, an empty object is returned and passed through to the next get. This is similar to null-safe-navigation in C#, which would be like obj?.name?.first
.