It’s a tough question, even philosophically. It’s as if you were in SQL land and you said “SELECT * FROM TABLE WHERE ROW DOES NOT EXIST”.
If your array is very multidimensional and sparse, there could potentially be a very large number of empty cells.
For a small, bounded array you can try a build/merge trick. We build a shape that’s the same size as foo, populated densely with a missing code that we know isn’t present in foo. We then merge that with foo and filter for the missing code:
$ iquery -aq "merge(foo, build(foo, missing(1)))"
$ iquery -aq "filter(merge(foo, build(foo, missing(1))), missing_reason(val)=1)"
For multiple attributes, you’d have to use apply(build()) to make a mask with more attributes, and then use a filter expression with multiple terms… Again - this wouldn’t work quickly for sparse arrays that have billions of possible logical cells.