Siebel eScript Language Reference > Siebel eScript Language Overview > Data Types in Siebel eScript >

Special Data Types in Siebel eScript


This section discusses the undefined, null, and NaN (not a number) data types.

Undefined

If a variable is created or accessed with nothing assigned to it, it is of type undefined. An undefined variable merely occupies space until a value is assigned to it. When a variable is assigned a value, it is assigned a type according to the value assigned.

Although variables may be of type undefined, there is no literal representation for undefined. Consider the following invalid fragment:

var test;
if (typeof test == "undefined")
TheApplication().RaiseErrorText("test is undefined");

After var test is declared, it is undefined because no value has been assigned to it. However the test, test == undefined, is invalid because there is no way to represent undefined literally.

Null

Null is a special data type that indicates that a variable is empty, and this condition is different from undefined. A null variable holds no value, although it might have previously held one.

The null type is represented literally by the identifier, null. Because Siebel eScript automatically converts data types, null is both useful and versatile.

Because null has a literal representation, an assignment such as the following is valid:

var test = null;

Any variable that has been assigned a value of null can be compared to the null literal.

NaN

The NaN type means "not a number," and NaN is an abbreviation for the phrase. However, NaN does not have a literal representation. To test for NaN, the function, isNaN(), must be used, as illustrated in the following fragment:

var Test = "a string";
if (isNaN(parseInt(Test)))
TheApplication().RaiseErrorText("Test is Not a Number");

When the parseInt() function tries to parse the string "a string" into an integer, it returns NaN, because "a string" does not represent a number as the string "22" does.

Siebel eScript Language Reference