This chapter mainly introduces how to determine whether a JavaScript object is empty.

When making asynchronous (Ajax) requests, sometimes an empty object is returned, as follows:

var a = {};

So how do we determine whether the returned object is empty?

The method is as follows:

Example

function isEmpty(obj) {
    return Object.keys(obj).length === 0;
}

Try it »