How to deep check for “null” or “undefined” with JS?
问题 In a Node.JS project, let's say I have a response from an API or any other object with a structure like { data: { info: { user: { name: "Hercules", password: "Iamthegreatest!" email: "hercules@olymp.gr" } } } } Accessing the members of the object is pretty easy. However, checking the existence before accessing any value gets PITA. I can assume that data is always present. Info, user, name, password and email may be present or may not. There can be a valid info object without an user and there