There is another special value occasionally used by JavaScript. This is the "undefined" value returned when you use a variable that doesn't exist, or a variable that has been declared, but never had a value assigned to it, or an object property that doesn't exist.
Unlike the null value, there is no undefined keyword for the undefined value. This can make it hard to write JavaScript code that detects this undefined value. The undefined value is not the same as null, but for most practical purposes, you can treat it as if it is. This is because the undefined value compares equal to null. That is, if we write:
my.prop ==index.html null
In Navigator 3.0 and later, you can distinguish between null and the undefined value with the typeof operator (which is discussed in detail in Chapter 4, Expressions and Operators). This operator returns a string that indicates the data type of any value. We said above that null is actually a object value, and when we use typeof on null, it indicates this by returning the string "object":
type =index.html typeof null; // returns "object"
var new_undefined_variable; type =index.html typeof new_undefined_variable // returns "undefined"
file: /Techref/language/JAVA/script/definitive/ch03_09.htm, 5KB, , updated: 2019/10/14 15:00, local time: 2024/11/25 15:41,
18.119.159.196:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://ecomorder.com/techref/language/JAVA/script/definitive/ch03_09.htm"> [Chapter 3] 3.9 Undefined</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.