I have a javascript object called file, I am trying to check if this object has file.xhr.response property contained in it. I have tried like this..
if (file.xhr.response) {
console.log(Exists);
} else {
console.log(Missing);
}
This works when file.xhr.response exists but if it doesn't then it throws an error...
Uncaught TypeError: Cannot read property 'response' of undefined
Where am I going wrong?
Cannot read property 'response' of undefined
it doesn't mean thatresponse
doesn't exist but rather then it's parent doesn't exist, in your casexhr
.response
is not defined but the code you put in the question doesn't useresponse
at all. The problem is not in the code you've shared.