How to determine the better method of undefined of in JS

  • 2020-03-30 02:29:37
  • OfStack

Recent project problems. Out to share with you.

After using a servlet to assign a value to the HTML page text box, use alert to pop up the value. The result is "undefined".

There is no way, can only Google, to find the god.

The original typeof must be used, which is:
 
if(typeof(value)=="undefined"){ 

alert("undefined"); 

} 

So you can pop "undefined";

Typeof returns a String, six possibilities :"number" "String" "Boolean" "object" "function" "undefined"

Related articles: