How to check undefined, empty and null in JavaScript/JQuery ?

By Hardik Savani | January 12, 2016 | | 719 Viewer | Category : Javascript jQuery


Share this post:

If you are working on jquery and However you want to check variable is undefined or not then you can easily check by typeof operator, which is simple, fast and cross-platform:

if(typeof i == "undefined"){

alert('undefined');

}

If you are working on jquery and However you want to check variable is empty or not then you can easily check by compare with empty string:

if(i == ''){

alert('Empty');

}

If you are working on jquery and However you want to check variable is null or not then you can easily check by compare with "null":

if(i == null || i == NULL){

alert('null');

}

Try this......