In this post, I am going to explain “How to check object is empty or not” in javascript/JQuery because there are many place we require to check object is empty, null or undefined etc. So usually we can check using $.isEmptyObject().
In javascript to check empty object, how to check empty object in jQuery, jQuery.isEmptyObject() example, jquery check object is null, jquery check object is empty, jquery check object is empty or not, how to check JSON object is empty or not in jquery.
1 2 3 4 5 6 7 |
if($.isEmptyObject(your_object)){ alert("This Object is empty."); }else{ alert("This Object is not empty."); } |
You can also check other way to your object is empty or not.
1 2 3 4 5 6 7 |
if (your_object && your_object instanceof Array && !your_object.length) { console.log('This Object is empty.'); } else { console.log('This Object is not empty.'); } |
I hope you found your best…
I’m a full-stack developer. My hobby and profession to write blog and programming tips that helps to others. I am a great admirer of PHP, Laravel, Codeigniter, AngularJS, Vue.js, Javascript, JQuery, WordPress, Plugin Development, Theme Development and Bootstrap from the early stage.
Leave a Reply