0
I have an object, where in some requests the same returns without certain values.
The problem, that when trying to validate the values, it generates error:
Note: When analyzing, I realized the following situation:
Code:
var a = {f : 1}
console.log(a) //{f: "Olha"}
console.log(a.b) //undefined
console.log(a.b.c) //Uncaught TypeError: Cannot read property 'c' of undefined at window.onload
The big problem is whether the previous value has not been set. Because it is a third-party API, I don’t know if which values can be set.
How do I validate in this type of situation?
Jsfiddle:
Apparently your error reports that the property does not exist or is "null"
speed
... consider adding to your question the relevant part of the code in question in this way it will be more likely that you actually get a satisfactory answer.– Lauro Moraes