Menu

Showing posts with label check empty on JSON object using JavaScript. Show all posts
Showing posts with label check empty on JSON object using JavaScript. Show all posts

How to check JSON object or JS object is empty?

if (!Object.keys(jsonObj).length === 0) {
    console.log("JSON object have some keys and values");
} else {
    console.log("JSON object is empty");
}


Here jsonObj is JSON or JavaScript object.