Minifycode 2020-03-07 Viewed 1.3K times Javascript

In this article, you will learn how to check empty undefined null string in JavaScript?

In this post, How to check empty undefined null string in JavaScript

if(!!str){
    // your code here
}

To checking if a string is blank or contains only white space

String.prototype.isEmpty = function() {
    return (this.length === 0 || !this.trim());
};

To checking if a string is blank, null or undefined I use

function isBlank(str) {
    return (!str || /^\s*$/.test(str));
}

To checking if a string is empty, null or undefined I use

function isEmpty(str) {
    return (!str || 0 === str.length);
}

How to check empty undefined null string in JavaScript?
minify code