Chapter 3 DynaScript Predefined Objects


Object object

Object

Allows you to create an instance of an object that is set depending on the type of value that is passed in as a parameter.

Standard: ECMAScript

Syntax

To use an Object property:

Object.propertyName

To use an Object method:

Object.MethodName( parameter ) 

Description

The actual object that is created when using this constructor varies depending on the parameter that is supplied. For example, if you supply a Boolean value such as true (new Object(true); ) a Boolean object is created. The only time that an actual Object object is created is when no value or null is supplied as the constructor parameter.

To create a new Object object, use:

myObj = new Object ( [parameter] );

Example

This example creates several different objects:

<!--SCRIPT 
    //creates a Boolen object
    myObj1 = new Object(true);
    document.WriteLn(typeof(myObj1));
    //creates a Script object
    myObj2 = new Object("my object");
    document.WriteLn(typeof(myObj2));
    //creates a Date object
    myObj3 = new Object( new Date( 1997, 01, 01 ) );
    document.WriteLn(myObj3);
    document.WriteLn(typeof(myObj3));
    //creates a Number object
    myObj4 = new Object(123);
    document.WriteLn(typeof(myObj4));
    //creates a Objec object
    myObj4 = new Object();
    document.WriteLn(typeof(myObj4));
-->

toString method

Syntax

Object.toString( )

Description

Returns the value of the object as a string.

Return

String

Example

To display the value of the myObj object:

<!--SCRIPT 
    myObj = new Object( "my object" );
    document.WriteLn( myObj.toString() );
-->

valueOf method

Syntax

Object.valueOf( )

Description

Extracts the value of the object.

Return

Integer

Example

To return the value of the myObj object:

<!--SCRIPT 
    myObj = new Object(null);
    document.WriteLn( typeof( myObj ) );
    document.WriteLn( "value = " + myObj.valueOf() );
-->

 


Copyright © 2001 Sybase, Inc. All rights reserved.