JSFiddle - React, Tailwind, and code Playground

by Gabriel Esquivel

HTML

<p><strong>First Result:</strong></p>
<p id="firstResult"></p>
<p><strong>Second Result:</strong></p>
<p id="secondResult"></p>

JavaScript

// The following values are always falsy:
// false.
// (zero)
// "" (empty string)
// null.
// undefined.
// NaN (a special Number value meaning Not-a-Number!)

function isNullOrEmpty(s){
    return (s == null || s == "")
}

(function (){  
    var firstResult = $("#firstResult");
    var secondResult = $("#secondResult");
  //isNullorEmpty 
    
    if( isNullOrEmpty(null) && isNullOrEmpty('') && isNullOrEmpty(undefined)){ 
      firstResult.text('they are all not null or empty'); 
        
    }else{ 
      firstResult.text('not possible');
    } 

  //isNullorEmpty is not necessary
   if(undefined || null || ''){ 
     secondResult.text('imposible'); 
   }else{ 
     secondResult.text('see they are falsy');
   }  
})();