1// simple check do the job
2if (myString) {
3 // comes here either myString is not null,
4 // or myString is not undefined,
5 // or myString is not '' (empty).
6}
1if( value ) {
2 //
3}
4
5/**
6* This will evaluate to true if value is not:
7* null
8* undefined
9* NaN
10* empty string ("")
11* 0
12* false
13*/
1/**
2 * Checks the string if undefined, null, not typeof string, empty or space(s)
3 * @param {any} str string to be evaluated
4 * @returns {boolean} the evaluated result
5*/
6function isStringNullOrWhiteSpace(str) {
7 return str === undefined || str === null
8 || typeof str !== 'string'
9 || str.match(/^ *$/) !== null;
10}