As title says, I have the following array:
var viewModel = [{}, {}, {}];
At some point in my code I may populate the 2nd element:
var viewModel = [{}, { "test" : "value" }, {}];
I need a way of evaluating if the elements are empty or not. In the above case, elements 0 and 2 will evalute to true, and element 1 will evaluate to false.
What I've Tried
I've tried comparing each element to undefined
and ' '
to no avail. I know could probably check for the test
property of each element (if it exists it's not empty) but I ideally wanted a way of determining this independent of any property names.
(I've tagged jQuery as I'm open to jQuery suggestions).