i know first sounds duplicate question don't think is...
i receiving json array as:
var test1 = [] ;
or
var test2 = [{},{},{}] ; //this empty
i have no problem finding out if test1
empty.
jquery.isemptyobject(test1)
my problem test2
... please note in cases test2 might return like:
var test2 = [{"a":1},{},{}] ; //all these not empty var test2 = [{},{"a":1},{}] ; //all these not empty var test2 = [{},{},{"a":1}] ; //all these not empty
the above scenarios shouldn't counted empty.i've tried use .length
it's not helping length 3... ideas?
cheers.
function isarrayempty(array) { return array.filter(function(el) { return !jquery.isemptyobject(el); }).length === 0; }
passes of tests.
a pure javascript solution replace !jquery.isemptyobject(el)
object.keys(el).length !== 0
edit: using array.prototype.every
function isarrayempty(array) { return array.every(function(el) { return jquery.isemptyobject(el); }); }