Check if variable is 'undefined' or 'null'

to check if javascript variable is undefined or nul use :

      if(typeof variable_here === 'undefined'){
         // your code here.
      };

      if(typeof variable_here === 'undefined'){
         // your code here.
      };
  1. <code>
  2. if(typeof variable_here === 'undefined'){
  3. // your code here.
  4. };
  5. </code>
<code>
      if(typeof variable_here === 'undefined'){
         // your code here.
      };

</code>
OR :

     if(! variable_here){
        // your code here.
     };

     if(! variable_here){
        // your code here.
     };
  1. <code>
  2. if(! variable_here){
  3. // your code here.
  4. };
  5. </code>
<code>
     if(! variable_here){
        // your code here.
     };

</code>

Popular posts from this blog

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken='xxx' or one of its dependencies.

C# Crop white space from around the image

The specified version string contains wildcards, which are not compatible with determinism.