title: How to check empty in variable in Google Apps Script
body: <p>I have a variable that can be either empty, number or text.  I like to find only empty one. But the following codes using .length returned null for 0 number, though it returned 1 for &quot;0&quot; string .  .toString.length even didn't work.  Any suggestion?  Thank you!</p>
  <pre><code>function test() {
    // criteria can be either empty, number or text. How can I check whether the critieria is empty?
    // In the example below, critiera_2.length returned null, not 1.
    criteria_1 = &quot;&quot;;
    Logger.log(criteria_1.length);
    criteria_2 = 0;
    Logger.log(criteria_2.length);
    criteria_3 = &quot;0&quot;;
    Logger.log(criteria_3.length);
    criteria_4 = &quot;X&quot;;
    Logger.log(criteria_4.length);
  
  
    criteria_1 = &quot;&quot;;
    Logger.log(criteria_1.toString.length);
    criteria_2 = 0;
    Logger.log(criteria_2.toString.length);
    criteria_3 = &quot;0&quot;;
    Logger.log(criteria_3.toString.length);
    criteria_4 = &quot;X&quot;;
    Logger.log(criteria_4.toString.length);
  }
  </code></pre>