javascript - How to check existence of a deep property -
is there improve solution next code:
if (response && response.responsejson && response.responsejson.message) { //code }
what you're doing fine. looks little ugly, makes clear what's going on. if wanted to, set total look in try-catch block, poor practice , harder read/maintain.
i imagine want groovy's "safe navigation operator", do:
if (response?.responsejson?.message)
but javascript not have this.
javascript
No comments:
Post a Comment