Read about javascript check undefined or null, The latest news, videos, and discussion topics about javascript check undefined or null from alibabacloud.com
.
JavaScript undefined attributes
Definition and usage
The undefined attribute is used to store the undefined value of JavaScript.
Syntax
Undefined
Description
You cannot use the for/in loop to enumerate the
"Alert (typeof a5); // displays "object"Alert (typeof a6); // displays "object"Alert (typeof a7); // display "number"Alert (typeof a8); // display "undefined"From the code above, we can see that undefined is undefined for undefined values and definitions. null is a special o
"Object"Alert (typeof A6); Show "Object"Alert (typeof A7); Show "Number"Alert (typeof A8); Show "Undefined"
As you can see from the code above, undefined values and undefined undefined,null is a special Object,nan is a special number.
2. Comparison operationvar A1; The va
Most computer languages have and have only one value that represents "none", for example, the Null,java language of the C language, the Null,python language of the None,ruby language of nil.Oddly enough, the JavaScript language actually has two values that represent "none": Undefined and
Most computer languages have and have only one value that represents "none", for example, the Null,java language of the C language, the Null,python language of the None,ruby language of nil.Oddly enough, the JavaScript language actually has two values that represent "none": Undefined and
to null and (2) Nan is unequal to any value and not equal to itself. nbsp; JavaScript undefined properties nbsp; definitions and usages undefined properties are used to store JavaScript undefined values. nbsp; Syntax
"alert (typeof A6);//Display "Object"alert (typeof A7);//display "number"alert (typeof A8);//Show "undefined"you can see from the above code that undefined values and definitions are unassigned for Undefined,null is a special Object,nan is a special number. 2. Comparison Operationsvar A1; The value of A1 is undefinedva
the two are equal.
if (!undefined) console.log('undefined is false');// undefined is falseif (!null) console.log('null is false');// null is falseundefined == null// true
The code abo
inverse compiled text of the function is displayed. The following example illustrates the use of the caller property:
Caller Demo {
function Callerdemo () {
if (callerdemo.caller) {
var a= callerDemo.caller.toString ();
alert (a);
} else {
alert ("This was a top function");
}
function Handlecaller () {
callerdemo ();
}
Execution results:
C.undefined and Null
---------------------------------------------------------------------------
In javascript, how does one determine whether a variable is null, undefined, Or NaN? Let's take a look at the specific judgment method.
It is mainly determined through the typeof method. typeof returns a string and has six possible results: "number", "string", "boolean", "object", "function", and "undefined ".
1. Deter
Reproduced from:
Author: one pixel
Www.cnblogs.com/onepixel/p/7337248.html
In a recent book on "JavaScript Advanced Programming", which mentions the equality operator (= =), you cannot convert null and undefined to any other value until you compare equality, but remember that null = =
) {var a=else {alert ("This I S a top function "); }}function Handlecaller () {Callerdemo ();} Handlecaller (); Execution Result: C.undefined and Null
Most computer languages have and have only one value that represents "none", for example, the Null,java language of the C language, the Null,python language of the None,ruby language of nil. Oddly
following example illustrates the use of the caller property:// Caller Demo {function Callerdemo () {if (callerdemo.caller) {var a= callerDemo.caller.toString (); alert (a); Else { alert ("This is a top function");} } function Handlecaller () { callerdemo ();} Handlecaller ();Execution Result: C.undefined and Null
Most computer languages have and have only one value that represents "none", for example, the
down.The concept of NULL, undefined, and Nan1. In JS, I have always felt that the difference between undefined and null is not very small, usually use the time will not be too concerned. Generally speaking:Undefined generally means "nonexistent" at all, and null means defin
So, after thinking carefully, write down this article, please heroes to shoot bricks.
Generally known:
Null = = undefined
But:
Null!== undefined
So what's the difference between the two?
Null
This is an object, but is empty. Because it is an object, typeof
JavaScript has two special data types: undefined and null. The following section describes the null judgment and the undefined judgment. The following is an incorrect usage: varexpundefined; if (expundefined) {alert JavaScript has
a value assigned.Null represents a reference data type that is not assigned a value.Let's look at a piece of code:
12345678
var age; var id = 100;var div02 = document.getElementById("div02");//注:div02是不存在的var div01 = document.getElementById("div01");//注:div01存在alert(id);//100alert(age);//undefinedalert(div02);//nullalert(div01);//object
Let's take a look at the memory situation:Solve the first question: Why Undefine inherits from nullIn
Oddly enough, the JavaScript language actually has two values that represent "none": Undefined and null. Why is that?
First, similarity
In JavaScript, assigning a variable to undefined or null is, to be honest, almost indistin
In JavaScript development, people ask: what is the difference between null and undefined? A bad time to answer, especially undefined, because it involves the implementation of undefined principle.General known: null = = undefinedH
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.