Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Siebel eScript Commands > User-Defined Objects in Siebel eScript > Predefining Objects with Constructor Functions in Siebel eScriptA constructor function creates an object template. For example, a constructor function to create Rectangle objects might be defined like the following: function Rectangle(width, height) The keyword this is used to refer to the parameters passed to the constructor function and can be conceptually thought of as "this object." To create a Rectangle object, call the constructor function with the "new" operator: var joe = new Rectangle(3,4) This code fragment creates two rectangle objects: one named joe, with a width of 3 and a height of 4, and another named sally, with a width of 5 and a height of 3. Constructor functions create objects belonging to the same class. Every object created by a constructor function is called an instance of that class. The preceding example creates a Rectangle class and two instances of it. Instances of a class share the same properties, although a particular instance of the class may have additional properties unique to it. For example, if you add the following line: you add a motto property to the rectangle joe. But the rectangle sally has no motto property. |
Siebel eScript Language Reference |