Bookshelf Home | Contents | Index | PDF |
Siebel eScript Language Reference > Methods Reference > Custom Methods > How the Constructor Function Creates an ObjectA constructor function creates an object template. To create a rectangle object, the following example uses a constructor function: function Rectangle(width, height) The following keyword references the arguments that the constructor function receives: You can think of the this keyword as meaning this object. Example of Using a Constructor FunctionTo create a rectangle object, the following example uses the new operator to call the constructor function: var joe = new Rectangle(3,4) This code creates the following rectangle objects: This example creates a Rectangle class and two instances of this class. A constructor function creates objects that belong to the same class. Every object that a constructor function creates is an instance of that class. Class instances share the same properties, although a single class instance can possess more unique properties. For example, adding the following code to the example adds a motto property to the joe rectangle. The sally rectangle does not include a motto property: |
Siebel eScript Language Reference | Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices. | |