I think you are looking for the in
operator, combined with the for
loop. Check this MDN
or try like this:-
for (var property in object) {
if (object.hasOwnProperty(property)) {
// do stuff
}
}
In your case:-
for (var fieldName in scope.filters) {
if (scope.filters.hasOwnProperty(fieldName))
{
//.....
}