Hello dev’s
Hope all are feeling good and okay . Today in this tutorial I will show How to check Object is empty or not in js . Now you can easily check that your JavaScript OR jQuery code object is empty or not. Because we need to check many place our application that jQuery object is empty or not, null or undefined etc. So usually, we can easily check by using $.isEmptyObject() as i explained it under.
Read Also : Angularjs PHP MySQL Pagination Example
How to check empty object in our Jquery. Now we show how to check empty object in jquery by using jQuery.isEmptyObject() example, jquery check object is null, jquery check object is empty, jquery check object is empty or not, how to check json objects are empty or not by using jquery, also can check if json objects are empty or not by using jquery
if($.isEmptyObject(your_object)){ alert("This Object is empty."); }else{ alert("This Object is not empty."); }
Read Also : Angular Bubble Chart Example Tutorial
We can also check it by other way to our object is empty or not. I also describe under.
if (your_object && your_object instanceof Array && !your_object.length) { console.log('This Object is empty.'); } else { console.log('This Object is not empty.'); }
Read Also : PHP AngularJS CRUD with Search and Pagination Example From Scratch
Now you can try this.Hope it will help you. Also you can follow us on Facebook .