I am trying to create for javascript / jquery test to check if my object is empty and cannot understand.
Here is an object when there is something in it:
{"mergedSellerArray":{"key1114":"1120"}}
And here is the object when empty:
{"mergedSellerArray":{}}
This is an ongoing test based on another SO answer, but it does not work:
var sellers = JSON.stringify({mergedSellerArray});
if(Object.keys(sellers).length === 0 && sellers.constructor === Object) {
console.log("sellers is empty!");
}
source
share