I have a variable which is as follows.
let response = [
{}
];
Which is an array with an empty object. What kind of check should I put in place to determine if this response is exactly equal to this. i.e,
[{}] === response; // returns false
I want to have a check that returns false if the response is [{}] how do i do that.
There are already questions on stack-overflow which asks on how to check for an empty object. My Question is that how do I check for an array with an empty object. So completely different. This is no duplicate of any question.
Array.isArray(response) && response.length === 1 && typeof response[1] === 'object' && Object.keys(response[1]).length === 0arr.length === 1 && isEmptyObject(arr[0])whereisEmptyObjectis an implementation suggested in the other question.