VaR Exp=Null;
If(!Exp)
If exp is undefined, zero number, or false, the same result is obtained as null, although null is different from the two.Note: This method can be used to determine null, undefined, zero, or false at the same time.
VaR
wrote a str = "s" + +;Then nan appeared for a while.The information collected is as follows:1. Judge undefined:?
1234
vartmp = undefined; if(typeof(tmp) == "undefined"){ alert("undefined"); }
Description: typeof
In JavaScript, we are often exposed to the 5 more special objects mentioned in the topic--false, 0, empty strings, null, and undefined. These objects are easy to use, so you have to be careful when you use them.Type detectionLet's come down and see
wrote a str = "s" + +;
Then there was Nan, and for a while.
The information collected is as follows:
1. Judge undefined:
Copy Code code as follows:
var tmp = undefined;
if (typeof (tmp) = = "undefined") {
Alert ("undefined");
}
wrote a str = "s" + +;Then nan appeared for a while.The information collected is as follows:1. Judge undefined:The code is as follows:1 style= "Font-size:small;" > var tmp = undefined; 2 if (typeof (tmp) = = "undefined") {3alert ("undefined"); 4
In JavaScript, we are often exposed to the 5 more special objects mentioned in the topic--false, 0, empty strings, null, and undefined. These objects are easy to use, so you have to be careful when you use them.Type detectionLet's come down and see
Boolean expressionAn expression with a value of true or false . Non-Boolean expressions can also be converted to a Boolean value if desired, but the following rules are followed:
All objects are treated as true.
The string is treated as
Boolean expressionAn expression with a value of true or false . Non-Boolean expressions can also be converted to a Boolean value if desired, but the following rules are followed:
All objects are treated as true.
The string is treated as
1, Nan (not a number) is not numeric, not equal to any number, including itself, can be judged by isNaN (), when Praseint () and prasefloat () can not parse the return NaN. Nan is a property under the Number object, number. NaNtypeof (NaN)//return
Copy Code code as follows:
null,undefined, the memory occupancy of the string with the talk
Summary:
The other thing to note is that NULL is an object type but it is very special and is stored in the stack stack. You can
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
CopyCode The Code is as follows:
null, undefined, memory usage of strings
conclusion:
// Another note is that although null is an object type, It is very special and stored in the stack itself. You can understand it as a special form of
Str = "s" ++;Then Nan appears. Find it for a while.The collected data is judged as follows:1. Determine undefined:Copy codeThe Code is as follows: var tmp = undefined;If (typeof (tmp) = "undefined "){Alert ("undefined ");} Note: typeof returns a
Copy codeThe Code is as follows: null, undefined, memory usage of strings conclusion: // Another note is that although null is an Object type, It is very special and stored in the stack itself. You can understand it as a special form of Object.//
JavaScript Data Type JavaScript Data Type
I. Introduction
The data type is introduced because it is combined with operators and how to determine the type of a variable may be confusing. For example, the result after the combination of data types
This article mainly introduces the conversion of data types in javascript, which has some reference value. Let's take a look at it below. 1. convert other data types to the number type.
Number ()-> strict
ParseFloat/parseInt-> non-strict
IsNaN
Logic and (&&)Logic and (&&) operations can be applied to any type of operation, not just Boolean values,The,&& operator does not necessarily return a Boolean value if there is an operand that is not a Boolean: follow these rules:1. If the first
At work we are constantly writing code, writing JavaScript, very little time for conceptual research. I have nothing to do today, I studied the relationship between "null" and "0". I hope you have seen the end of the harvest.
Alert (null>=0)
What
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.