How to check Object is empty or not in Jquery/JavaScript?
You can check your JavaScript OR jQuery object is empty or not, because we need to check many place our jQuery object is empty, null or undefined etc., So usually, we can check using $.isEmptyObject() as i explained as under.
how to check empty object in javascript, 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, check if json object is empty jquery
if($.isEmptyObject(your_object)){
alert("This Object is empty or Null.");
}else{
alert("This Object is not empty or Null.");
}
$.isEmptyObject() function returns true or false means if a object or variable gets null value or empty then it returns true otherwise false. So in another way comparing with object true or false you can write a code for your project.
You can also check other way to your 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.');
}
null checking in jquery is really very much important. So try this in your projects and if you found any problem to understand, please comment I will definitely try to give you a right answer.
How to check Object is empty or not in Jquery/JavaScript?
Reviewed by Ashok Sen
on
01:09:00
Rating:
No comments:
Post a Comment