I am getting the error
Cannot read property 'billingDate' of undefined
installment here is undefined
response.detailsResponse.installment.billingDate
I want to use hasOwnProperty but in a dynamic way, like I pass the path and the object (to check against) to a function, it does the following checks and return true or false.
function checkProperty(path, obj){
//assuming path = response.detailsResponse.installment.billingDate
//assuming obj = response [a json/object]
//check if response.detailsResponse exists
//then check if response.detailsResponse.installment exists
//then check if response.detailsResponse.installment.billingDate exists
}
The path length/keys can vary.
The code has to be optimized and generic.