How to Judge-null js in JS How to judge-undefined JS how to judge-string type of number
The following is an incorrect method: var exp = undefined;
if (exp = = undefined)
{
Alert ("undefined");
}
When exp is null, it also gets the same result as undefined, although null and undefined are different. Note: This method can be used to determine both undefined and null. var exp = undefined;
if (typeof exp = = undefined)
{
Alert ("undefined");
}
typeof returns a string of six possible types: number, String, Boolean, object, function, undefined.
The following is the correct method: var exp = undefined;
if (typeof exp = "undefined")
{
Alert ("undefined");
}
The following are the simpler and more correct methods (if the variable is neither Var nor assigned, the following error occurs, but at this point the programmer, not JavaScript) is to be reviewed: var exp = undefined;
if (exp = = undefined)
{
Alert ("undefined");
}