DEV Community

Discussion on: Different ways to check If Object is empty or not

Collapse
 
awesome_aj1298 profile image
Arpit Jain

Thanks 😊, The best approach is utility function

function isEmpty(obj) {
    for(var prop in obj) {
        if(obj.hasOwnProperty(prop))
            return false;
    }

    return true;
}
Collapse
 
vetrivel profile image
Vetrivel p

I am not understood, please explain brielfy, I am beginner in JS.