I'm trying to step through an object to make sure none of the properties are undefined. I found this question and this question and implemented the following code, but it does not work.
for (var property in p.properties) {
if (p.properties.hasOwnProperty(property)) {
if (typeof property == 'undefined') {
p.properties[property] = '';
//a breakpoint here will NOT be hit
}
}
}
However, if I explicitly check the one that I know has undefined values, it does work:
if(typeof p.properties.st == 'undefined') {
p.properties.st = '';
//a breakpoint here WILL be hit
}
Here is how the data is obtained:
$.getJSON("data/stuff.json", function (data) {
$.each(data.features, function (i, p) {
//checking for undefined properties here
}
});