Easy Tutorial
❮ Javascript Autocomplete C Array As Parameter ❯

How to Determine if a JavaScript Object is Empty?

Category Programming Techniques

This section primarily introduces how to determine if 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 if the returned object is empty?

Here is the method:

Example

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

** Click to Share Notes

Cancel

-

-

-

❮ Javascript Autocomplete C Array As Parameter ❯