By jQuery
, I can tell if a Object
is empty as follows:
$.isEmptyObject({}); // true
$.isEmptyObject(window); // false
To know if a array
is empty, we can do the same thing, but without jQuery
it would look like this:
var arr = []
arr.length == 0; // True
But what about Object
? How can I find out if it is empty?
I figured I could do this:
Object.keys(obj).length == 0;
But I thought it was not very suitable.
What other possible ways to do this?
Note : I would like the answer to be without the use of jQuery
and others, but only using pure javascript.